--查询出产品价格大于15元并且一次被购买数量超过1个的产品。
--1.
select a.product_id,a.name from
(select * from products p where p.price>15) a inner join
(select * from purchases pr where pr.quantity>1) b on
a.product_id=b.product_id
--2.
select p.product_id,p.name from products p inner join purchases pr
on p.product_id=pr.product_id and p.price>15 and pr.quantity>1;
--3.
select p.product_id,p.name from products p where p.price>15 and p.product_id in
(select pr.product_id from purchases pr where pr.quantity>1);
--4.
select p.product_id from products p where p.price>15
intersect
select pr.product_id from purchases pr where pr.quantity>1

 

posted on 2016-05-23 15:15  是小亦啊  阅读(276)  评论(0编辑  收藏  举报