mysql 获取当前id数据的前后数据
作者:
领带衬有黄金 | 来源:发表于
2019-12-04 09:17 被阅读0次
方式一
{$id} 代表当前id值
select * from table_a where id = (select id from table_a where id < {$id} order by id desc limit 1);
select * from table_a where id = (select id from table_a where id > {$id} order by id asc limit 1);
方式二
select * from table_a where id = (select max(id) from table_a where id < {$id});
select * from table_a where id = (select min(id) from table_a where id > {$id});
本文标题:mysql 获取当前id数据的前后数据
本文链接:https://www.haomeiwen.com/subject/swyructx.html
网友评论