Code: Select all
DELETE FROM criterion_stats
JOIN criterions ON criterion_stats.criterion_id = criterions.id
JOIN adgroups ON adgroup_id = adgroups.id
JOIN campaigns ON campaign_id = campaigns.id WHERE keyword IN ('k1','kw2');
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN criterions ON criterion_stats.criterion_id = criterions.id
JOIN adgroups ' at line 2
Though according to the MySQL Manual, I'm allowed to use JOIN statements in a delete query:
MySQL supports the following JOIN syntaxes for the table_references part of SELECT statements and multiple-table DELETE and UPDATE statements
Code: Select all
join_table: table_reference [INNER | CROSS] JOIN table_factor [join_condition] | table_reference STRAIGHT_JOIN table_factor | table_reference STRAIGHT_JOIN table_factor ON condition | table_reference LEFT [OUTER] JOIN table_reference join_condition | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor | table_reference RIGHT [OUTER] JOIN table_reference join_condition | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor