0

I'm trying to delete some data from 3 tables. Here is my SQL:

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'].

And here is the output error:

Error Number: 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

What does it mean and how can I fix it?

Goran Jovic
  • 9,418
  • 3
  • 43
  • 75
user1114281
  • 1
  • 1
  • 2

1 Answers1

1

Your DELETE statement should be:

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

OR

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

OR do not add single quote if field type is numeric.

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

Have a look at DELETE JOIN syntax.

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186