How about order and limit?
SELECT * FROM table_name WHERE status = 1 AND id > 1 ORDER BY id ASC LIMIT 1;
You should look into setting the indexes correctly here also, to ensure top performance.
Question
/id/desription/status/
--------------------
/1/testing01/ 1 /
/2/testing02/ 0 /
/3/testing03/ 1 /
/4/testing04/ 1 /
Hi,
I need to query next id where status = 1
If mySQL Query, I need query id next to id = 1 where status = 1
SELECT * WHERE id = (1 + 1) AND status = 1 ?
So my outcome is id number 3.
Thanks for the help, appreciate lots.
Solution
How about order and limit?
SELECT * FROM table_name WHERE status = 1 AND id > 1 ORDER BY id ASC LIMIT 1;
You should look into setting the indexes correctly here also, to ensure top performance.