Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含 order_by 列的表,其中包含值 Ex:
4,10 ,20 ,80,500,625,712
我想修改为:
1,2,3,4,5,6,7
如果 80 的阶数为 4,则值为 4
我想做这样的事情:
UPDATE tablex SET order_by=ORDER_OF(order_by);
set @rownum := 0; UPDATE tablex as t SET t.order_by = @rownum := @rownum + 1 order by t.order_by
SQLFiddle 示例