RE: [PHP-DB] LIMIT in MSSQL

From: Date: Wed, 23 Aug 2000 14:05:05 +0000
Subject: RE: [PHP-DB] LIMIT in MSSQL
Groups: php.db 
Request: Send a blank email to php-db+get-2298@lists.php.net to get a copy of this message
I am having the same problem. The only way I have come up with is to "order by" the primary key and use limits. So say you have a table that contains names and the primary key is an autonum. table-> names -------------- | pri | name | -------------- 1 Greg 2 Joe 3 Sam 4 John 5 Jill 6 Jane 7 Sam 8 Laura 9 Jen 10 Karl So you do a "SELECT TOP 2 * FROM names ORDER BY pri WHERE pri > 0" which gives you "Greg" and "Joe". Now when the user clicks "Next 2 rows", you do this SQL: "SELECT TOP 2 * FROM names ORDER BY pri WHERE pri > 2", which gives you "Sam" and "John". Very messy stuff, but the best I can think of. Anyone else have a better idea? Greg Breland Web Master American HealthTech > -----Original Message----- > From: Matthew Beers [mailto:mbeers@udeco.com] > > I want to be able to do something like: > > SELECT * FROM Table1 LIMIT 100, 10 > > but in MSSQL.

« previous php.db (#2298) next »