2015-10-16 70 views
1

我使用刪除一些記錄,語法錯誤而刪除加入

delete FROM product_to_category c inner JOIN product_description d 
ON c.product_id = d.product_id 
WHERE c.category_id IN (3, 6) 
GROUP BY c.product_id 
HAVING COUNT(DISTINCT c.category_id) = 2 
ORDER BY d.name asc 

但它返回語法錯誤附近使用c inner JOIN product_description............

誰能告訴我怎麼構建我的查詢正確

任何建議,將不勝感激

+0

嘗試'刪除product_to_category FROM product_to_category INNER JOIN product_description d' –

回答

0

如果你有多個表(連接),你需要指定刪除哪個表。

DELETE T1 
FROM T1 
INNER JOIN T2 ON T1.key = T2.key 
WHERE condition 
+0

它不能正常工作,現在它的返回錯誤在'group by' –