首页 > 数据库技术 > 详细

160523SQL简单的四种查询语句

时间:2016-05-23 16:40:58      阅读:195      评论:0      收藏:0      [点我收藏+]

--查询出产品价格大于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

 

技术分享

160523SQL简单的四种查询语句

原文:http://www.cnblogs.com/zq926/p/5520101.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!