mysql查询首先根据id倒序排序,然后把下一条的某个字段值赋值到当前字段需要怎么实现???
如果要赋值的是name,可以直接 select max(id),name from table_info where id <'当前id值' group by name,然后再将name值赋值给当前字段更新就好了吧
select
(select MAX(b.col1) from table1 b where b.id<a.id ),
a.*
from table1 a
ORDER BY a.id desc ;