码迷,mamicode.com
首页 > 数据库 > 详细

数据库里any 和 all 的区别

时间:2016-10-19 20:16:01      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:

 

any 是任意一个
all 是所有

比如
select * from student where 班级=‘01‘ and age > all (select age from student where 班级=‘02‘);
就是说,查询出01班中,年龄大于 02班所有人 的 同学
相当于
1
select * from student where 班级=‘01‘ and age > (select max(age) from student where 班级=‘02‘);


1
select * from student where 班级=‘01‘ and age > any (select age from student where 班级=‘02‘);
就是说,查询出01班中,年龄大于 02班任意一个 的 同学
相当于
1
select * from student where 班级=‘01‘ and age > (select min(age) from student where 班级=‘02‘);

数据库里any 和 all 的区别

标签:

原文地址:http://www.cnblogs.com/sq45711478/p/5978266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!