数据库里any 和 all 的区别

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');

posted on 2016-10-19 15:00  向前看!明天会更好!  阅读(766)  评论(0编辑  收藏  举报