一直习惯于使用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>