dmcglone Posted April 28, 2013 Share Posted April 28, 2013 I am having a really hard time understanding how to delete when using a table join. I've looked up examples on here and on the web and I've tried to adopt them to what I need and I'm not having any luck.I have a table named properties and a table named additional_info, and all I am trying to do is delete the corresponding information in the additional_info table that goes to the MLS_id it is joined with in the properties table.Here's some code I have been playing with $MLS_id = $_GET['MLS_id']; $this->query = ("DELETE properties, additional_info FROM properties LEFT JOIN properties.MLS_id ON additional_info.info_id = properties.MLS_id WHERE additional_info.info_id = $MLS_id"); Where am I going wrong? Thanks, David M. Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/ Share on other sites More sharing options...
Barand Posted April 28, 2013 Share Posted April 28, 2013 Do you want to delete the rows from both tables or just from additional_info? Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/#findComment-1427016 Share on other sites More sharing options...
dmcglone Posted April 28, 2013 Author Share Posted April 28, 2013 Both tables. Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/#findComment-1427030 Share on other sites More sharing options...
Solution Barand Posted April 28, 2013 Solution Share Posted April 28, 2013 DELETE properties, additional_info FROM properties LEFT JOIN additional_info ON additional_info.info_id = properties.MLS_id WHERE properties.MLS_id = $MLS_id Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/#findComment-1427035 Share on other sites More sharing options...
dmcglone Posted April 28, 2013 Author Share Posted April 28, 2013 Thank you. I think I understand. It'll probably take me a few minutes to wrap my head around it, after that I'll be asking myself "What was I thinking?" Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/#findComment-1427038 Share on other sites More sharing options...
Barand Posted April 29, 2013 Share Posted April 29, 2013 Is this now solved? Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/#findComment-1427096 Share on other sites More sharing options...
dmcglone Posted April 29, 2013 Author Share Posted April 29, 2013 Is this now solved? Yes. I appreciate the help. I forgot to also mark the thread as solved.. (I'll do that now) Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/#findComment-1427113 Share on other sites More sharing options...
Barand Posted May 1, 2013 Share Posted May 1, 2013 mysqlquestions - I think we've already established that, but thanks for your advert Quote Link to comment https://forums.phpfreaks.com/topic/277391-deleting-and-table-join/#findComment-1427621 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.