Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2007
    Posts
    15

    Unanswered: Id of next Record

    I have a asp web page which calls a stored procedure passing into it a record id from a querystring

    http://www.example.com/index.asp?id=123

    the web page displays all info related to record id 123

    select * from table where id= 123

    I want to also have a link at the bottom of the webpage to the next record

    <a href="http://www.example.com/index.asp?id=127'>next page</a>

    How do I get the next record Id the table?
    Last edited by aish1108; 06-03-08 at 23:51.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT MIN(id) AS next_id
      FROM daTable
     WHERE id > 123
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Rudy got it, just add this as a second SELECT statement to the current procedure, and use its output for the link.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  4. #4
    Join Date
    Aug 2007
    Posts
    15

    Talking Thanks!

    Thanks, this has been keeping me up at night for days.
    Seriously!

Posting Permissions

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