timtom3 Posted November 30, 2005 Share Posted November 30, 2005 Is it possible to delete information from two tables with one delete statement? For example DETELE * FROM product p, images i WHERE product_id.p = images_id.i ? Becuase when I try this it doesn't work? Quote Link to comment Share on other sites More sharing options...
widgetapps Posted November 30, 2005 Share Posted November 30, 2005 You certainly can, but your syntax is off a little. [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']DELETE[/span] t1, t2 FROM t1, t2, t3 WHERE t1.id=t2.id AND t2.id=t3.id; [!--sql2--][/div][!--sql3--] You can get all the details you need in the MySQL documentation as well: [a href=\"http://dev.mysql.com/doc/refman/4.1/en/delete.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/4.1/en/delete.html[/a] Quote Link to comment Share on other sites More sharing options...
timtom3 Posted November 30, 2005 Author Share Posted November 30, 2005 Something wrong with this??? DELETE FROM product p, images i WHERE p.product_ID = '.$product_ID.' AND i.prod_id = '.$product_ID.' Product table Product_ID (primary key) Image table prod_id has to match product_id Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.