我正在执行以下查询
DELETE FROM List,Tree WHERE List.CatID = Tree.CatID AND List.ID = '1' AND Tree.Cat = '332'
但我遇到了以下错误
near ",": syntax error
答案 0 :(得分:0)
删除语句的正确语法是这个
DELETE FROM table_name WHERE somecolumn=somevalue
因此,您不能在单个删除查询中使用2个表,只需用逗号分隔它们。
您需要执行类似
的操作DELETE something FROM table_name INNER JOIN...
答案 1 :(得分:0)
您一次只能从一个表中删除,并且必须将连接重写为子查询:
DELETE FROM List
WHERE ID = '1'
AND CatID IN (SELECT CatID
FROM Tree
WHERE Cat = '332')