一直習慣於使用any,昨天發現語法中還有個some,網上搜了下,其實沒什麼區別,效果都是一樣的,由於英文語法,any一般用於不等於的情況,而some用於等於的情況。
示例如下:
SQL> desc t
Name Null? Type
------ -------- -------------
ID NUMBER(38)
SQL> select * from t;
ID
----------
1
2
3
SQL> desc n
Name Null? Type
----------------------------------------- -------- ------------
ID NUMBER(38)
SQL> select * from n;
ID
----------
3
4
SQL> select * from t where id =some(select id from n);
ID
----------
3
SQL> select * from t where id =any(select id from n);
ID
----------
3
SQL> select * from n where id >some(select id from t);
ID
----------
3
4
SQL> select * from n where id >any(select id from t);
ID
----------
3
4
SQL>