设置本ID为3两个语句:
上一条为
select * from tablename where id < 3 limit 1;
下一条为
select * from tablename where id > 3 limit 1;
上一条为
select * from tablename where id < 3 limit 1;
下一条为
select * from tablename where id > 3 limit 1;
order by id
我想问为何非要在sql语句上下功夫?
记录不多的话,一次select出来用php数组比较不是更好?记录很多的话其实编程者大概对id分布也心里有数,select一个范围出来再比较就可以了如果是必然需求的话
优化数据库字段结构才是好的选择