LoginSignup
6
9

More than 5 years have passed since last update.

UPDATEやDELETEにLIMIT指定ができることを知った

Last updated at Posted at 2015-11-10

全レコードをUPDATEやDELETEする恐怖から開放される。

参考

動作確認

14レコードある
mysql> select count(*) from messages WHERE stat = 'hoge';
+----------+
| count(*) |
+----------+
|       14 |
+----------+
1 row in set (0.00 sec)
limit2で2レコード消える
mysql> delete from messages WHERE stat = 'hoge' limit 2;
Query OK, 2 rows affected (0.00 sec)
12レコードある
mysql> select count(*) from messages WHERE stat = 'hoge';
+----------+
| count(*) |
+----------+
|       12 |
+----------+
1 row in set (0.00 sec)
6
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
9