mysql怎样查询下一条数据
发布时间:12/01 来源:未知 浏览:
关键词:
mysql查询下一条数据的办法:从news表里按从小到大的次序选中一条比目前ID大的数据,代码为【table_a where id = (select min(id) from table_a where id > {$id})】。
mysql查询下一条数据的办法:
猎取目前文件下一笔记录的道理是下一条的sql语句,从news表里按从小到大的次序选中一条比目前ID大的数据。
要是ID是主键或者有索引,可以直接查寻:
办法1:
1.select * from table_a where id = (select id from table_a where id < {$id} order by id desc limit 1); 2.select * from table_a where id = (select id from table_a where id > {$id} order by id asc limit 1);
办法2:
1.select * from table_a where id = (select max(id) from table_a where id < {$id}); 2.select * from table_a where id = (select min(id) from table_a where id > {$id});
更多相干免费学习举荐:mysql教程(视频)
以上就是mysql怎样查询下一条数据的细致内容,更多请关注 百分百源码网 其它相干文章!