【发布时间】:2021-07-28 05:37:15
【问题描述】:
我有桌子tblOptionsAssets
它包含如下字段:
id (Primary Key)
position_id (simply the position number used to arrange data from position_id number 1 up to last row)
height (int)
我有样本记录
id | position_id | height
1 | 2 | 12
2 | 1 | 36
3 | 3 | 24
我想更新position_id 值ASCENDINGLY,其中height 列按ASC 排序
预期输出:
id | position_id | height
1 | 1 | 12
2 | 3 | 36
3 | 2 | 24
如果我这样选择:
SELECT * FROM tblOptionsAssets ORDER BY position_id ASC
会返回类似的东西
id | position_id | height
1 | 1 | 12
3 | 2 | 24
2 | 3 | 36
更新
在我当前的设置中,有这样的行:
id | position_id | height
1 | 2 | 12
2 | 1 | 36
3 | 3 | 24
4 | 4 | 36
5 | 5 | 36
【问题讨论】:
标签: mysql