株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

@iで変数定義、それをインクリメント

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>

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)