简体   繁体   中英

mysql compress order_by values

I have a table with a column order_by whit the values Ex:

4,10 ,20 ,80,500,625,712

I want modify to:

1,2,3,4,5,6,7

If order of 80 is 4 the value will be 4

I want to do something like this :

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 example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM