Select record # 25 - 45 in SQL
2010-10-08
How to select a specified range records in SQL? such as from #25 to #45 ?
Here are some code to resolve:
**record 1 - 20: **
SELECT TOP 20 * from member where ... order by ID
**record 21 - 40: **
SELECT TOP 20 * from member where ... AND ID NOT IN (SELECT TOP 20 ID FROM member order by ID) order by ID
**record 41 - 50: **
SELECT TOP 10 * from member where ... AND ID NOT IN (SELECT TOP 40 ID FROM member order by ID) order by ID