Oracle: '= ANY()' vs. 'IN ()'

后端 未结 9 1388
难免孤独
难免孤独 2020-12-01 03:37

I just stumbled upon something in ORACLE SQL (not sure if it\'s in others), that I am curious about. I am asking here as a wiki, since it\'s hard to try to search symbols in

9条回答
  •  生来不讨喜
    2020-12-01 04:03

    MySql clears up ANY in it's documentation pretty well:

    The ANY keyword, which must follow a comparison operator, means “return TRUE if the comparison is TRUE for ANY of the values in the column that the subquery returns.” For example:

    SELECT s1 FROM t1 WHERE s1 > ANY (SELECT s1 FROM t2);

    Suppose that there is a row in table t1 containing (10). The expression is TRUE if table t2 contains (21,14,7) because there is a value 7 in t2 that is less than 10. The expression is FALSE if table t2 contains (20,10), or if table t2 is empty. The expression is unknown (that is, NULL) if table t2 contains (NULL,NULL,NULL).

    https://dev.mysql.com/doc/refman/5.5/en/any-in-some-subqueries.html

    Also Learning SQL by Alan Beaulieu states the following:

    Although most people prefer to use IN, using = ANY is equivalent to using the IN operator.

提交回复
热议问题