【发布时间】:2010-12-23 11:07:17
【问题描述】:
我有一张如下表,
| id | name | color |
------+--------+---------
| 1 | pear | green |
| 2 | apple | red |
| 3 | banana | yellow |
| 4 | grape | purple |
我想使用“名称”列按字母顺序重新排序,并用这个新顺序重置 id(自动增量)以得到以下结果
| id | name | color |
------+--------+---------
| 1 | apple | red |
| 2 | banana | yellow |
| 3 | grape | purple |
| 4 | pear | green |
问题:如何使用 MYSQL 做到这一点?
【问题讨论】:
-
为什么要id顺序匹配name顺序?
标签: mysql alphabetical