BMS-HOSxP Community

HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: Bond_007 ที่ ตุลาคม 21, 2013, 17:19:59 PM

หัวข้อ: มีคำถามการเขียน sql ครับ
เริ่มหัวข้อโดย: Bond_007 ที่ ตุลาคม 21, 2013, 17:19:59 PM
มีคำถามการเขียน sql ครับ
ถ้า select * from person ได้ 10000 reccord
ถ้า select * from person limit 1000 จะได้ 1000 reccord
คำถามคือ จะทำยังไง select * from person limit 1000 จำนวน 10 ครั้งโดยที่ข้อมูลเมื่อ select มาไม่ซ้ำกัน คือเมื่อมารวมกันแล้วจะเท่ากับ select * from person
ขอบคุณครับ
หัวข้อ: Re: มีคำถามการเขียน sql ครับ
เริ่มหัวข้อโดย: khaimok ที่ ตุลาคม 21, 2013, 19:15:00 PM
มีคำถามการเขียน sql ครับ
ถ้า select * from person ได้ 10000 reccord
ถ้า select * from person limit 1000 จะได้ 1000 reccord
คำถามคือ จะทำยังไง select * from person limit 1000 จำนวน 10 ครั้งโดยที่ข้อมูลเมื่อ select มาไม่ซ้ำกัน คือเมื่อมารวมกันแล้วจะเท่ากับ select * from person
ขอบคุณครับ

select * from person  order by person_id  limit 0,1000  (ครั้งที่ 1)
select * from person  order by person_id  limit 1000,1000  (ครั้งที่ 2)
select * from person  order by person_id  limit 2000,1000  (ครั้งที่ 3)
.............
select * from person  order by person_id  limit 9000,1000  (ครั้งที่ 10)

ลองดูครับ