What does the MySQL
USING statement do and is there any docs on this?
MySQL USING statement example
DELETE FROM l, s USING l INNER JOIN s ON s.skill_id = l.id WHERE s.user_id = 3
In a DELETE, you can list tables after the USING clause, from which rows do not get deleted (i.e., to only be part of the WHERE clause). For example:
DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id AND t2.id=t3.id;
Your particular example can be achieved without USING in this fashion:
DELETE l,s FROM l INNER JOIN s ON s.skill_id = l.id WHERE s.user_id = 3
The USING clause is used to set column existence criteria for two tables in a JOIN.
So, if I have a statement such as:
SELECT * from a JOIN b USING (c1,c2) ...
what will happen is that the MySQL engine will first verify that columns
c2 exist in both tables, and then compare the values of those columns to perform the join on the two tables.
See MySQL documentation for JOIN Syntax.
USING in the MySQL documentation for DELETE. It is just an alternative syntax.
USING statement –
DELETE LOW_PRIORITY QUICK IGNORE FROM tbl_name.* , tbl_name.* ... USING table_references WHERE where_condition
for detailed info visit USING