2013-12-15 64 views
0
DELETE FROM Table1 
INNER JOIN View1 ON Table1.ID = View1.ID 
WHERE Table1.ID = View1.ID; 

錯誤是沒有結束的正確如何從一個表使用聯接SQL刪除行

+0

可能重複[如何刪除使用INNER JOIN與SQL Server?(http://stackoverflow.com/questions/16481379/how-delete-using- inner-join-with-sql-server) –

回答

1

你如何做這取決於SQL的方言。下面是應該在任何數據庫工作的方法:

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

要刪除的記錄指定表的SQL命令,

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

仍然沒有正常結束!我編輯了SQL,Table2實際上是一個View。 – meltonCG

1
DELETE Table1 
FROM Table1 
INNER JOIN View1 
ON Table1.ID = View1.ID; 
相關問題