Click to See Complete Forum and Search --> : Multi Delete


tbirnseth
04-14-2010, 02:09 PM
I have the following SQL statement for mySQL 5.0:

DELETE ezc_shipping_services, ezc_shipping_service_descriptions, ezc_shippings
FROM ezc_shipping_services as ss
LEFT JOIN ezc_shipping_service_descriptions as sd ON ss.service_id = sd.service_id
LEFT JOIN ezc_shippings as s ON s.service_id = ss.service_id
WHERE ss.module='tnt'


It is generating the following error:

Database error: Unknown table 'ezc_shipping_services' in MULTI DELETE (1109)
Invalid query: DELETE ezc_shipping_services, ezc_shipping_service_descriptions, ezc_shippings FROM ezc_shipping_services as ss LEFT JOIN ezc_shipping_service_descriptions as sd ON ss.service_id = sd.service_id LEFT JOIN ezc_shippings as s ON s.service_id = ss.service_id WHERE ss.module='tnt';


The table(s) do exist and I "thought" the SQL syntax was correct. What I'm trying to do is delete all entries in the 3 tables that JOIN correctly with ezc_shippiing_services.module='tnt' where they all have the same 'service_id'.

Any insights? I'm guessing I have something syntactically wrong with the SQL statement but can't see what.

SOLVED
Change Query to:

DELETE ss, ssd, s, sd
FROM ezc_shipping_services as ss
LEFT JOIN ezc_shipping_service_descriptions as ssd ON ss.service_id = ssd.service_id
LEFT JOIN ezc_shippings as s ON s.service_id = ss.service_id
LEFT JOIN ezc_shipping_descriptions as sd ON sd.shipping_id = s.shipping_id
WHERE ss.module='tnt';