在DBMS中包含以下三个表:
Customer(Id, Name, City),
Product(Id, Name, Price),
Orders(Cust_Id, Prod_Id, Date)
获取已订购所有产品的客户(如果有)的查询是什么?
答案 0 :(得分: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)