MySQL Forums
Forum List  »  Newbie

DELETE query in PHP
Posted by: Ugis Revelis
Date: July 28, 2005 06:20AM

Hi!

I spent 3 h to figure out how to write this query and still nothing...
The problem is, that I have 3 tables and if I delete some record from the first table, I want to delete from other 2 tables too...

------ DB Content ------

Table 1 - t_country

c_id
c_name


Table 2 - t_manufacturer

m_id
m_country_id
m_name


Table 3 - t_wine

w_id
w_manufacturer_id
w_name

------ DB Content ------


So - if I delete some country, I want to delete all subordinate manufacturers and wines too...
I used "Multiple-table syntax":


------ Query Content ------

$del = conutry id number

DELETE t_country, t_manufacturer, t_wine
FROM t_country, t_manufacturer, t_wine
WHERE t_country.c_id = $del
AND t_manufacturer.m_country_id = $del
AND t_wine.w_manufacturer_id = ?

------ Query Content ------


(? - I cant figure out what to write here!!!)
Maybe I wrote invalid syntax?!

Please help if you can...
Thanks!

Ugis

Options: ReplyQuote


Subject
Written By
Posted
DELETE query in PHP
July 28, 2005 06:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.