Jump to content

Recommended Posts

lets say i have 10 tables

 

a b c d e f g h i j

 

a has and id

 

the rest have a a_id as afield

 

i want to delete a, and any of the other ones that might exist and have an a_id of the a i am deleting.

 

i do not want to do 10 queries  and i cant quite figure out how to use the correct syntax for one query can someone please help me.

 

 

:'(

I'm looking for something like this:

 DELETE FROM a left join b,c,d,e,f WHERE a.id='sdf'=b.aid=c.aid=d.aid=e.aid=f.aid

 

im just looking for the right syntax.

 

i dont want to do this

 DELETE FROM a WHERE id='asd'
DELETE FROM b WHERE aid='asd'
DELETE FROM c WHERE aid='asd'
DELETE FROM d WHERE aid='asd'
DELETE FROM e WHERE aid='asd'
DELETE FROM f WHERE aid='asd'

 

 

 

 

How about:

 

DELETE 
a, b, c, d, e, f 
FROM a 
left join b on ( a.id=b.aid )
left join c on ( a.id=c.aid )
left join d on ( a.id=d.aid )
left join e on ( a.id=e.aid )
left join f on ( a.id=f.aid )
WHERE a.id='sdf'

 

But I think there might be something wrongwith your table structure.

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.