Yammyguy Posted March 19, 2009 Share Posted March 19, 2009 Hoping someone can answer my little question here... I have two tables: Demand: ID | year | month | day | time | KV | kVAr | kVA | PF | source 1 | 2008 | 4 | 1 | 21:00 | 2786.4 | 0 | 2786.4 | 1 | MS1 2 | 2008 | 4 | 3 | 21:00 | 2485.4 | 0 | 2526.4 | 1 | MS2 3 | 2008 | 11 | 26 | 21:00 | 9531.4 | 0 | 7543.4 | 1 | NSLS services: ID | name | full 1 | MS1 | City's MS1 2 | MS2 | City's MS2 3 | NSLS | City's Net System Load Shape I was wondering what the syntax would be if I wanted to remove all rows from both tables containing - for example - the value "MS1". Thanks in advance for everyone's help! Quote Link to comment https://forums.phpfreaks.com/topic/150082-solved-removing-entries-from-two-tables-containing-same-value-with-one-statement/ Share on other sites More sharing options...
Yammyguy Posted March 19, 2009 Author Share Posted March 19, 2009 This is what I've tried: DELETE FROM demand JOIN services ON (demand.source=services.name) WHERE name = 'TEST' This is the error I'm getting: #1064 - 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 'JOIN services ON (demand.source=services.name) WHERE name = 'TEST'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/150082-solved-removing-entries-from-two-tables-containing-same-value-with-one-statement/#findComment-788191 Share on other sites More sharing options...
fenway Posted March 19, 2009 Share Posted March 19, 2009 This is what I've tried: DELETE FROM demand JOIN services ON (demand.source=services.name) WHERE name = 'TEST' Try: DELETE demand, services FROM demand INNER JOIN services ON (demand.source=services.name) WHERE services.name = 'TEST' I'm assuming that you want to delete both rows... Quote Link to comment https://forums.phpfreaks.com/topic/150082-solved-removing-entries-from-two-tables-containing-same-value-with-one-statement/#findComment-788277 Share on other sites More sharing options...
Yammyguy Posted March 19, 2009 Author Share Posted March 19, 2009 That's exactly what I was looking for! Thank you VERY VERY much! ;D Quote Link to comment https://forums.phpfreaks.com/topic/150082-solved-removing-entries-from-two-tables-containing-same-value-with-one-statement/#findComment-788588 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.