Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Recordset Paging Alphabetically....

Author  Topic 

interclubs
Yak Posting Veteran

63 Posts

Posted - 2003-12-14 : 12:10:07
Not sure if this is even possible, but suppose I have a table with info such as:

ID|Name
---------------
1, Scott
2, Bob
3, Bill
4, Shelly

And that I have selected the info from the table where name='Scott'... Would it be possible to select the next ID based upon the name field.... E.G. I am looking at the Scott Record, and I want the next one (if they were sorted alphabetically) meaning the 'Shelly' record, or ID 4.

I am trying to add Next and Previous buttons to my website so that users can page through the different names alphabetically but am stuck trying to figure out the query I would need.

Does that make sense?

nr
SQLTeam MVY

12543 Posts

Posted - 2003-12-14 : 13:21:17
select top 1 ID from tbl where name > 'Scott' order by Name

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -