zed420 Posted November 30, 2008 Share Posted November 30, 2008 Hi All Can someone tell me if this is possible or do I need to wake up. I'm trying to delete some records from three different tables at once via check boxes, tabls don't have any join. This doesn't give me any error but not working either. It does work if I use one table. some help will be greatley appreciated. if($_POST['delete']) { foreach($_POST as $job_id) { mysql_query("DELETE FROM job_tb,blockBook,blockBook2 WHERE job_tb.job_id='$job_id' OR blockBook.job_id= '$job_id' OR blockBook2.job_id= '$job_id'"); if (mysql_affected_rows() > 0) { print "<font color=red size=2>Job No. = $Job_id has been deleted</font><p>"; } } } Thanks Zed Link to comment https://forums.phpfreaks.com/topic/134901-deleting-from-three-tables-at-once/ Share on other sites More sharing options...
Barand Posted November 30, 2008 Share Posted November 30, 2008 try DELETE job_tb.*, blockBook.*, blockBook2.* FROM job_tb INNER JOIN blockBook USING (job_id) INNER JOIN blockBook2 USING (job_id) WHERE job_tb.job_id = '$job_id' Link to comment https://forums.phpfreaks.com/topic/134901-deleting-from-three-tables-at-once/#findComment-702487 Share on other sites More sharing options...
zed420 Posted November 30, 2008 Author Share Posted November 30, 2008 Thanks for the reply Barand It didn't work . Zed Link to comment https://forums.phpfreaks.com/topic/134901-deleting-from-three-tables-at-once/#findComment-702496 Share on other sites More sharing options...
Barand Posted November 30, 2008 Share Posted November 30, 2008 If there are no matching job_ids you'll need 3 separate deletes Link to comment https://forums.phpfreaks.com/topic/134901-deleting-from-three-tables-at-once/#findComment-702500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.