当前位置:Gxlcms > 数据库问题 > 数据库里any 和 all 的区别

数据库里any 和 all 的区别

时间:2021-07-01 10:21:17 帮助过:3人阅读

 

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 的区别

标签:

人气教程排行