There is a table with fields id and title . Record id known. How to get the next entry by id ? Suppose if id is 4 , then get a record with id 5 (or 66 , or 88 , depending on the number of the next record).

  • Maybe you need an order by id ? And if the sample, then what prevents you where id = @id+1 ? - nick_n_a
  • because id can be 4, 5, 6 and maybe 4, 66, 88 - duddeniska
  • five
    Emm ... SELECT * FROM table WHERE id > 4 ORDER BY id ASC LIMIT 0, 1 ? - Regent
  • @Regent can issue as an answer? It seems to fit the meaning. - Vadim Ovchinnikov
  • @VadimOvchinnikov full confidence that this is what is needed, no. The author never answered yes / no. But why not. - Regent

1 answer 1

Getting the next entry given the current entry id :

 SELECT * FROM table WHERE id > 4 ORDER BY id ASC LIMIT 0, 1