【发布时间】:2011-08-18 21:22:27
【问题描述】:
我在从 MySQL 的表中删除所需的行时遇到了困难。我正在使用一个相当复杂的子查询来选择行,但由于某种原因,我无法使用类似的语法删除它们。
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", ""));
同样,我可以选择要删除的确切行,但是当我将查询更改为删除时,我收到以下错误:
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...
非常感谢任何帮助。
【问题讨论】:
标签: mysql join subquery sql-delete