1

I am running a select SQL query:

select * from table where sequence = '6' 

i want to be able to get the next row however it may not be sequence 7, as this may not exist.

if the next row is sequence 9 how would i select it?

0

2 Answers 2

7

Order by sequence and use limit to define an offset of 1

select * from your_table
where sequence >= 6
order by sequence
limit 1, 1
Sign up to request clarification or add additional context in comments.

2 Comments

LIMIT 1,1 would skip the first... wait... oh, you're selecting WHERE >= 6.
Yes, because the next record may also be sequence = 6
0

I don't know if this can help...

select * from table where sequence > '6' order by sequence ASC limit 0,1

6 Comments

This will never select the row, if sequense is 6. It can also be 6.
sorry but the questioner have write it differently... he want the one AFTER the six... so i do no need to select the value 6 in sequence.. yes.. i missed the limit part... will be limit 0,1
No, he said after the code example "...as this may not exist."
If you want to quote, quote it completely "i want to be able to get the next row however it may not be sequence 7, as this may not exist." so the 7th can not exists. is how i read it ;)
Well that is not related to this.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.