Jump to content

[SOLVED] removing entries from two tables containing same value with one statement


Yammyguy

Recommended Posts

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!

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.