标签:
--查询出产品价格大于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
标签:
原文地址:http://www.cnblogs.com/zq926/p/5520101.html