|
 |
asp_databases thread: how to select from 3rd record to 10th record?
Message #1 by "yuenkit" <janet_smith2000@y...> on Sat, 30 Jun 2001 08:20:55
|
|
if i wan to retrieve the 3rd record to 10th records, or retrieve 5 records after
the 3rd records, how to do it?
I know there's a TOP statement "SELECT TOP x FROM tbl", but it retrieves
the 1st record till the x'th record.
Thanks!
Message #2 by "Dallas Martin" <dmartin@z...> on Sat, 30 Jun 2001 08:52:08 -0400
|
|
Here's one approach:
SELECT TOP 5 t1.table1_id
FROM table1 t1
WHERE t1.table1_id NOT IN (SELECT TOP 3 t2.table_id FROM table1 t2 ORDER BY
t2.table_id)
ORDER BY t1.table1_id
This will return the next 5 records after the the first 3.
Dallas Martin
----- Original Message -----
From: "yuenkit" <janet_smith2000@y...>
To: "ASP Databases" <asp_databases@p...>
Sent: Saturday, June 30, 2001 8:20 AM
Subject: [asp_databases] how to select from 3rd record to 10th record?
> if i wan to retrieve the 3rd record to 10th records, or retrieve 5 records
after
> the 3rd records, how to do it?
> I know there's a TOP statement "SELECT TOP x FROM tbl", but it retrieves
> the 1st record till the x'th record.
> Thanks!
Message #3 by "Simon Scheurer" <simon.scheurer@u...> on Sat, 30 Jun 2001 14:57:38 +0200
|
|
You can use the absolutePage and the pageSize property of
the Recordset object.
If you set
rs.pageSize = 5
rs.absolutePage = 3
then the recordset will start with record number 11 and
you can put a counter in your while loop to retrieve only
5 records
|
|
 |