Reputation: 129
I have 2 tables in my database.
table customer with ID,firstName,lastName,address...
and table orders with id, idCustomer...
and I want to delete all the orders of the customers where the first name is "john"
How I write the command?
thanks
Upvotes: 1
Views: 44
Reputation: 140
Delete From
orders
Where
Orders.firstName In
(Select
firstName
From
customers
Inner Join orders On customers.ID = orders.idCustomer
Where
customers.firstName = "john")
Upvotes: 0
Reputation: 93161
DELETE o
FROM Orders o
INNER JOIN Customer c ON o.idCustomer = c.ID
WHERE c.firstName = 'john'
Upvotes: 3