如何删除其他表中的条件的行(sql)

时间:2015-11-28 16:35:45

标签: mysql sql oracle

CUSTOMER ( Cid, CName, City, Discount )
AGENT ( Aid, AName, City, Percent )  
PRODUCT ( Pid, PName, City, Quantity, Price )  
ORDERS ( OrderNo, Month, Cid, Aid, Pid, OrderedQuantity, Cost )

Q- 删除居住在纽约市的代理商发出的所有订单。

1 个答案:

答案 0 :(得分:-1)

您可以使用in运算符:

DELETE
FROM   orders
WHERE  aid IN (SELECT aid
               FROM   agent
               WHERE  city = 'New York')