Perad Posted October 29, 2006 Share Posted October 29, 2006 This isn't working, i am not sure i quite grasp the concept of deleting from multiple tables.Basically i want to delete from news the record where id=$id and from news_comments where news_id=$idCould someone help me fix this query please. Thanks[code]"DELETE FROM news,news_comments WHERE news.id='$id', news_comments.news_id=$id"[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25467-mysql-query/ Share on other sites More sharing options...
wildteen88 Posted October 29, 2006 Share Posted October 29, 2006 Try this:"DELETE FROM news, news_comments WHERE news.id='$id' AND news_comments.news_id='$id'" Quote Link to comment https://forums.phpfreaks.com/topic/25467-mysql-query/#findComment-116234 Share on other sites More sharing options...
Perad Posted October 29, 2006 Author Share Posted October 29, 2006 Nope the error messages comes back withCould not connect to MySQL: 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 'WHERE news.id='10' AND news_comments.news_id='10'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/25467-mysql-query/#findComment-116247 Share on other sites More sharing options...
fenway Posted October 29, 2006 Share Posted October 29, 2006 I assume your version supports multi-table deletes? Quote Link to comment https://forums.phpfreaks.com/topic/25467-mysql-query/#findComment-116409 Share on other sites More sharing options...
toplay Posted October 29, 2006 Share Posted October 29, 2006 Perad, notice that in wildteen88 post there's single quotes around the $id variables. The error you posted seems to indicate that you're missing a single quote (on the right) at the second $id variable.... right syntax to use near 'WHERE news.id='10' AND news_comments.news_id='10'' at line 1should be:... news_comments.news_id='10' Quote Link to comment https://forums.phpfreaks.com/topic/25467-mysql-query/#findComment-116462 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.