oracle中some與any

 一直習慣於使用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>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章