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? Link to comment https://forums.phpfreaks.com/topic/2960-deleting-from-two-tables-with-one-statement/ 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] Link to comment https://forums.phpfreaks.com/topic/2960-deleting-from-two-tables-with-one-statement/#findComment-9953 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 Link to comment https://forums.phpfreaks.com/topic/2960-deleting-from-two-tables-with-one-statement/#findComment-9954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.