2011-12-24 151 views
0

我想從3個表中刪除一些數據。這是我的SQL:mysql:錯誤號:1064

DELETE 
FROM productdetail 
JOIN (productdescription,productmineralcategories,productspeciescategories) 
ON 
    (
    productdetail.id = productspeciescategories.id_product 
    AND productdetail.id = productmineralcategories.id_product 
    AND productdetail.id = productdescription.id_product 
    )  
    WHERE productdetail.id='".$data['id']. 

這裏是輸出錯誤:

錯誤編號:1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN (productdescription, productmineralcategories, productspeciescategories) ' at line 3

是什麼意思,我該如何解決?

回答

1

你DELETE語句應該是:

$query="DELETE 
     FROM productdetail 
     WHERE productdetail.id='".$data[$id] . "'"; 

OR

$query="DELETE 
     FROM productdetail 
     WHERE productdetail.id='$data[$id]'"; 

,或者如果字段類型是數字不加單引號。

$query="DELETE 
     FROM productdetail 
     WHERE productdetail.id=$data[$id]"; 

看一看DELETE JOIN syntax.