If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Selecting specific number of rows from a table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-08-06, 08:12
Jugular Bean Jugular Bean is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
Selecting specific number of rows from a table

Is there a way one can specify the number of rows to be selected.
Reason being I'm displaying results in multiple pages.

Say I want to select rows 20-30 from the recordset.

Currently I'm using a variable to keep track of the FromRow and scrolling to that Row, however is there a way to directly jump to that row?
Reply With Quote
  #2 (permalink)  
Old 08-08-06, 08:45
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
how you do (effectively) will depend on the particular database system you're using

in MySQL, you can use LIMIT 19,11

there's nothing in standard SQL
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-08-06, 08:50
Jugular Bean Jugular Bean is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
What bout MS SQL Server?
Reply With Quote
  #4 (permalink)  
Old 08-08-06, 08:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
see, this is why it helps to post in the correct forum -- the SQL forum is not for Microsoft SQL Server, it is for the SQL language

see http://rosca.net/writing/articles/serverside_paging.asp

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 08-08-06, 09:56
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
You could look into using a cursor. Fetch the number of rows you want. If you want some more rows, leave the cursor open and fetch some more.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On