T
T
TheMergus2019-09-11 18:21:17
Python
TheMergus, 2019-09-11 18:21:17

How to get next value from database?

How to get the next value?
For example:
the database has numbers 5,6,9,10,1,15
I delete the number 10, how can I get the next number?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey c0re, 2019-10-23
@erge

get the rowid of the desired record delete the record select the next record based on the received rowid + 1 specifically in this case the rowid of record 10 was equal to 4 and + 1, the next record with rowid >=5 :

-- выбираем слудющую запись по rowid(10) + 1 -> 4+1
select num
  from numbers
  where rowid >= 5 -- 4+1
  order by rowid
  limit 1;

see example on dbfiddle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question