Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> retreiving the "next" record using SQL
I'm new to SQL and have the following question:
I have a table whose primary key is a combination of 2 columns and the
data types are "number + alpha string". We need to do a "next" operation
but I don't seem to find something explicit in SQL for such a thing.
I tried doing
select * from tablename
where column1 >= presetvalue
and column2 >= 'presetvalue'
Well, it fails because if the "next" record's col2 may be alphabetically less than what the sql statement is asking for. Ex. find the next record after col1= 1, col2 = '00804008'
the next record is col1= 2, col2 = '000'
based on the above sql statement the real next record doesn't meet the
criteria, so we get something else
I'm sure this is a common ocurrence!
Received on Thu Oct 22 1998 - 09:33:35 CDT