Re: LIMIT in MSSQL
| From: | Manuel Lemos | Date: | Sat, 02 Sep 2000 23:15:40 +0000 |
| Subject: | Re: LIMIT in MSSQL | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2593@lists.php.net to get a copy of this message | ||
Hello Matthew,
On 22-Aug-00 19:04:14, you wrote:
>Does anyone have any ideas on how to structure a MSSQL sql statement
>to mimic the functionality of the MySQL LIMIT clause?
>I want to be able to do something like:
>SELECT * FROM Table1 LIMIT 100, 10
>but in MSSQL.
>I know about SELECT TOP, but it only allows for the TOP N records and
>I want to find information further in the recordset arbitrarily. There
>isn't an identity field that could be used for ordering either.
I have used server side cursors in MSSQL 6.5 because it doesn't even seem
to support the TOP clause. OTOH, I can just retrieve the rows of a select
query result that I want, skipping any initial rows.
I have used this in Metabase, a PHP database abstraction package. This
is meant to perform a similar effect of the LIMIT clause in MySQL. You
just call MetabaseSetSelectedRowRange($database_handle,$first_row,$limit);
and it just retrieves the row range you asked. This is also available for
other supported DBMS that don't support the LIMIT clause, like Oracle,
Informix, etc...
If you would like to take a look to how it works, you may download Metabase
source for free here:
http://phpclasses.UpperDesign.com/browse.html/package/20
Regards,
Manuel Lemos
Web Programming Components using PHP Classes.
Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org
--
E-mail: mlemos@acm.org
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--