I am getting a syntax error from MySQL when executing the following
query (names substituted):

Delete From Table1 WHERE Related_ID IN (SELECT Related_ID FROM Table2
WHERE Another_ID='1');

What is going wrong?

My guess is that the SELECT is considered a subquery, but how else do
you get the "selected rows" for the IN() argument?

Here is the relevant section from the manual:

A.5.5 Deleting Rows from Related Tables

As MySQL doesn't support subqueries (prior to Version 4.1), nor the use
of more than one table in the DELETE statement (prior to Version 4.0),
you should use the following approach to delete rows from 2 related
tables: 

SELECT the rows based on some WHERE condition in the main table. 

DELETE the rows in the main table based on the same condition. 

DELETE FROM related_table WHERE related_column IN (selected_rows). 

TIA,

zaxpaw at comcast dot net

Reply via email to