Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT 1

Status
Not open for further replies.

TheObserver

Programmer
Mar 26, 2002
91
US
Is there a way to do a "SELECT 1 from..." where I can stipulate a key and get the next ONE row of data from the database that is greater than the key value I supply?

IE:

SELECT NEXT FROM TABLE WHERE TABLE_ROW_ID > 1;

Let's say this returns a 3 as the table_row_id, along with the other data for that row.

Then I could repeat this as necessary:
SELECT NEXT FROM TABLE WHERE TABLE_ROW_ID > 3;

Thanks for your help.
 
There is no concept of next row in a relational DBMS. Order is only applicable to result sets, not tables. You can use a cursor to iterate through a result set.

What are you trying to do?
 
Have a look at Thread220-444040 and see if it helps your case.
Marc
 
Assuming you have some kind of auto-increasing key on the table (1, 2, 3, etc..) then:

Code:
SELECT TOP 1 *
FROM table1
WHERE index_col > 3
ORDER BY index_col

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top