I’m having difficulty deleting the desired rows from my table in MySQL. I’m using a rather complex subquery to select the rows, but for some reason I’m unable to delete them using a similar syntax.
delete * from table1 as t1
where t1.col1 in
(select y.col1
from table2 x
join
(select col1, col2
from table2
where col2 like "%- 2%") y
on x.col2 = replace(y.col2, "- 2", ""));
Again, I can select the exact rows I wanted deleted, but when I change the query to delete I get the following error:
ERROR 1064 (42000): 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...
Any help is greatly appreciated.
Remove the
*afterDELETE. You don’t usually delete individual columns, you delete entire rows.