資料庫ALL和ANY的區別

2021-08-05 23:26:07 字數 697 閱讀 2220

這兩個都是用於子查詢的

any 是任意乙個

all 是所有

any表示有任何乙個滿足就返回true,all表示全部都滿足才返回true

比如 :

select * from student where 班級=』01』 and age > all (select age from student where 班級=』02』);
就是說,查詢出01班中,年齡大於 02班所有人的同學 相當於

select * from student where 班級=』01』 and age > (select

max(age) from student where 班級=』02』);

select * from student where 班級=』01』 and age > any (select age from student where 班級=』02』);
就是說,查詢出01班中,年齡大於 02班任意乙個 的 同學 相當於

select * from student where 班級=』01』 and age > (select

min(age) from student where 班級=』02』);

資料庫裡any 和 all 的區別

any 是任意乙個 all 是所有 比如select from student where 班級 01 and age all select age from student where 班級 02 就是說,查詢出01班中,年齡大於 02班所有人 的 同學 相當於1 select from stud...

sql酷斃的any和all

今天下午從6點多想到現在,倆小時啊!我這是什麼腦袋啊!尤其any,真是有點暈,現在懂了。any和all通常與關係運算子一起使用,實現對子查詢返回值的判斷工作,如下 any比子查詢返回的任意結果大就行,即大於返回結果的最小值。any就是等於返回結果的任意值就行,等價於in。all比子查詢返回的所有結果...

Oracle中any和all的區別用法

對於any,all的用法,書中說的比較繞口,難以理解,如果通過舉例就會比較清晰.any的例子 select from t hq ryxx where gongz any select pingjgz from t hq bm 輸出的結果是所有大於字段 pingjgz 中最小數的值,簡單來說就是輸出的...