1

在 DBMS 中有以下三个表:

Customer(Id, Name, City),
Product(Id, Name, Price),
Orders(Cust_Id, Prod_Id, Date)

获取已订购所有产品的客户(如果有)的查询是什么?

4

1 回答 1

3
select c.id
from customer c
inner join orders o on o.cust_id = c.id
inner join product p on p.id = o.prod_id
group by c.id
having count(distinct p.id) = (select count(id) from product)
于 2013-05-14T15:33:19.560 回答