2012-11-15 147 views
2

我想從多個表中刪除具有相同條件的多行,但總是會返回語法錯誤。mysql刪除語法錯誤

這是代碼:

DELETE FROM table1,table2,table3 
WHERE guid = 'CE4EF453-937F-C7F9-7AE429VB0128' 

錯誤代碼是:

1064 - 你在你的SQL語法錯誤;檢查對應於你的MySQL服務器版本的手冊正確的語法使用

附近「其中GUID ='CE4EF453-937F-C7F9-7AE429VB0128」出現在第2行

+1

提供的連接條件 –

+0

見多表刪除http://dev.mysql.com/doc/refman/4.1/en/delete.html –

回答

1

您正在失去INNER JOIN。或許像以下

DELETE FROM table1,table2,table3 
USING table1 INNER JOIN table2 INNER JOIN table3 
WHERE table1.guid = 'CE4EF453-937F-C7F9-7AE429VB0128' 
    AND table2.guid = table1.guid 
    AND table3.guid = table1.guid 

(Reference)

+0

誤差不使用連接。謝謝。 – Hexxen

0

給這一個鏡頭:

DELETE FROM table1,table2,table3 
WHERE table1.guid = 'CE4EF453-937F-C7F9-7AE429VB0128' 
    AND table1.guid = table2.guid 
    AND table1.guid = table3.guid