数据库里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');

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