0
I have a database and would like to always fetch the value before, and I have used for example:
I will fetch a news, and on this page there is a link to the previous news, and I will search for the id of the current news - 1, but this way, it will for ids that may not exist or have been deleted, there is way to ignore the gaps and query again?
You can search on the condition that the id is smaller than the current one and limit it to the first record. For example: SELECT * FROM noticias WHERE id < 3 ORDER BY id DESC LIMIT 1 -- Previous
– Diego Schmidt