/id/desription/status/
--------------------
/1/testing01/ 1 /
/2/testing02/ 0 /
/3/testing03/ 1 /
/4/testing04/ 1 /
嗨,
我需要查询下一个状态 = 1 的 id
如果是 mySQL 查询,我需要 id = 1 旁边的查询 id,其中 status = 1
SELECT * WHERE id = (1 + 1) AND status = 1 ?
所以我的结果是 id 号 3。
感谢您的帮助, 非常感谢。
最佳答案
订单和限额怎么样?
SELECT * FROM table_name WHERE status = 1 AND id > 1 ORDER BY id ASC LIMIT 1;
您还应该考虑在此处正确设置索引,以确保最佳性能。
关于php - mySQL带参数查询下一个id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19355536/