MySQL – Using IN Clause Within a DELETE Command

MySQL

I am browsing through the official MySQL documentation to learn about the DELETE clause.
This page states

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]

I can see from this WHERE, ORDER BY and LIMIT is allowed but there is no mention of IN

Therefore the following valid command

DELETE FROM WHERE column = z OR column = y OR column = x OR column = w

However I wrote the following command which execute's fine and does exactly the same as the above but looks better.(possibly executes faster too)

DELETE FROM table WHERE column IN (z,y,x,w)

Am I allowed to do this? I am wondering if maybe it works in this case but other cases would fail?
Also if this is fine should'nt the docs state it?

Best Answer

Yes, you can use IN() in the WHERE clause of a DELETE statement.

There is no "IN clause" -- IN() is just a comparison operator, perhaps slightly disguised as something more sophisticated.

http://dev.mysql.com/doc/refman/5.6/en/comparison-operators.html#function_in

To illustrate what IN() is really doing, consider these examples in isolation.

mysql> SELECT 1 IN (2,3,4); -- should be false
+--------------+
| 1 IN (2,3,4) |
+--------------+
|            0 | -- is indeed false
+--------------+
1 row in set (0.00 sec)

mysql> SELECT 1 IN (2,1,4); -- should be true
+--------------+
| 1 IN (2,1,4) |
+--------------+
|            1 | -- is indeed true
+--------------+
1 row in set (0.00 sec)

...and, as @ypercube has pointed out, the "where_condition is an expression that evaluates to true for each row to be deleted".