Reputation:
I know it is a very silly question, and it may be found all over the internet, but still if you all dont mind i want someone to point out the problem in my query. I am using a single query to delete from multiple table, i dnt have any foreign keys in the two tables..
Here's the table structure of the two table
table 1: dt_my_domain
|----------|----------------|
| username | domain_email |
|----------|----------------|
and
table 2: dt_my_contact
|----------|-------|----------------|------------------|--------|
| user | email | contact_person | contact_email | type |
|----------|-------|----------------|------------------|--------|
now, the table dt_my_domain have username as primary key, and domain_email is unique.
similarly in table dt_my_contact email is unique.
I want to delete from the two table, on the basis of domain_email and email so that when the two matches the corressponding tuple gets deleted from the two tables
Here's the query i'm running,
DELETE FROM dt_my_domain, dt_my_contact
USING dt_my_domain
INNER JOIN dt_my_contact USING(email)
WHERE dt_my_domain.domain_email = '[email protected]'
so, its giving the database error
Unknown column 'email' in 'from clause'
Now How can i solve this by my query, I want to debug or the problem with this query
Upvotes: 0
Views: 4532
Reputation: 4957
DELETE d,c FROM dt_my_domain d inner join dt_my_contact c
on d.domain_email = c.email
WHERE d.domain_email = '[email protected]'
Upvotes: 1