Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2006
    Posts
    11

    Unanswered: 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?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2006
    Posts
    11
    What bout MS SQL Server?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •