如何使用连接SQL从表中删除行

时间:2013-12-15 19:16:46

标签: sql

DELETE FROM Table1
INNER JOIN View1 ON Table1.ID = View1.ID
WHERE Table1.ID = View1.ID;

错误是SQL命令未正确结束

3 个答案:

答案 0 :(得分:1)

指定要删除记录的表

DELETE Table1                        -- <== this will delete records from Table1
FROM   Table1
       INNER JOIN Table2 ON Table1.ID = Table2.ID
WHERE Table1.ID = Table2.ID;

答案 1 :(得分:1)

DELETE Table1
FROM   Table1
INNER JOIN View1
ON Table1.ID = View1.ID;

答案 2 :(得分:1)

如何执行此操作取决于SQL的方言。这是一个应该适用于任何数据库的方法:

DELETE FROM Table1
WHERE Table1.Id in (select Id from View1);