這兩個都是用於子查詢的
any 是任意一個
all 是所有
any表示有任何一個滿足就返回true,all表示全部都滿足才返回true
比如 :
select * from student where 班級=’01’ and age > all (select age from student where 班級=’02’);
- 1
就是說,查詢出01班中,年齡大於 02班所有人的同學 相當於
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’);
- 1
就是說,查詢出01班中,年齡大於 02班任意一個 的 同學 相當於
select * from student where 班級=’01’ and age > (select min(age) from student where 班級=’02’);