@iで変数定義、それをインクリメント
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
mysql> set @i :=0; Query OK, 0 rows affected (0.00 sec) mysql> UPDATE table set table_id = (@i := @i +1); Query OK, 5277 rows affected (0.08 sec) Rows matched: 5277 Changed: 5277 Warnings: 0 mysql> select table_id from table limit 10; +------------------+ | table_id | +------------------+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | +------------------+ 10 rows in set (0.00 sec) mysql> |