Delete from multiple tables in one query prt 2

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Delete from multiple tables in one query prt 2

Post by kendall »

Hey,

this is a continuation question from a posting i was reading in viewtopic.php?t=23774&highlight=delete+multiple

Now i have used

Code: Select all

DELETE FROM products, price_options, product_options USING products, price_options, product_options WHERE product_options.ProductID = products.ProductID AND price_options.ProductID = products.ProductID AND products.ProductID = 'test'
with much success but this is for delete relating information among the tables

but at the moment i am trying to apply this to tables that MAY NOT have related information. To put it more in sentance term.
Im trying to delete related data in tables that may or may not have matches.
I have been experimenting with the LEFT JOIN syntax of it but im sooo not getting the whole concept of LEFT JOIN when SELECT far less for using it with DELETE but how does the LEFT JOIN work in terms of precedence with DELETE?

What would be a solutions of DELETE multiple tables that may or may not have related data?

Kendall[/url]
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

If your table type supports them, set up cascading deletes in the relationships.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Cascading DELETES?

Post by kendall »

What in the BLUE HELL is
cascading DELETES?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

cascading deletes are ones using foreign keys set up such that "on delete" they destroy themselves too. Tightly tied records. :)
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

USING foreign keys

Post by kendall »

Unfortunately i am unable to impliment the foreign keys thingy


What to doooo what too doooooooooooooo :cry:
Post Reply