我的数据库中有2个表。
表客户ID,firstName,lastName,地址......
和包含id,idCustomer ......的表命令。
我要删除名字为“john”的客户的所有订单
我如何编写命令?
感谢
答案 0 :(得分:3)
DELETE o
FROM Orders o
INNER JOIN Customer c ON o.idCustomer = c.ID
WHERE c.firstName = 'john'
答案 1 :(得分:0)
Delete From
orders
Where
Orders.firstName In
(Select
firstName
From
customers
Inner Join orders On customers.ID = orders.idCustomer
Where
customers.firstName = "john")