On Thursday, Feb 17, 2005, at 15:29 US/Central, Ed Howland wrote:
This trick is easy, but syntax differs from SQL engine to engine.

For MySQL it is:

select * from table limit [offset,] row_count

Very nice.

For others:
You have to select the limit <rows_per_page> not in the limit ((current_page - 1) * rows_per_page)


E.g. for SQL Server

select top 10 * from tablea where tablea.pk not in (select top 10 pk from tablea)
for page 2 etc.


Note you have to put the exact same where clauses in both selects if you need them.

Wow, subselects for getting the middle rows. Interesting. It'd probably be worthwhile to create a temporary table with the first field being an auto-increment. Then you could just do an join and restrict on the value in the auto-increment number.


Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent

_______________________________________________
CWE-LUG mailing list
http://www.cwelug.org/ [email protected]
http://lists.firepipe.net/listinfo/cwe-lug

Reply via email to