我有一个如下表,它有一个 ID 和项目名称、订单和类型。
+--------+----------------+-----------+---------+
| ID | ITEM | ORDER | TYPE |
+--------+----------------+-----------+---------+
| 1 | Banana | 2 | Fruit |
+--------+----------------+-----------+---------+
| 2 | Apple | 1 | Fruit |
+--------+----------------+-----------+---------+
| 3 | Orange | 4 | Fruit |
+--------+----------------+-----------+---------+
| 4 | Lemon | 3 | Fruit |
+--------+----------------+-----------+---------+
如果我要删除Lemon
,那ORDER
就是 1,2,4。有没有一种方法可以重新索引剩余项目以获得以下结果?
+--------+----------------+-----------+---------+
| ID | ITEM | ORDER | TYPE |
+--------+----------------+-----------+---------+
| 1 | Banana | 2 | Fruit |
+--------+----------------+-----------+---------+
| 2 | Apple | 1 | Fruit |
+--------+----------------+-----------+---------+
| 3 | Orange | 3 | Fruit |
+--------+----------------+-----------+---------+