Skip to content
Advertisement

Oracle: ‘= ANY()’ vs. ‘IN ()’

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 google…

I just found that when checking a value against a set of values you can do

As opposed to the usual

So I’m curious, what is the reasoning for these two syntaxes? Is one standard and one some oddball Oracle syntax? Or are they both standard? And is there a preference of one over the other for performance reasons, or ?

Just curious what anyone can tell me about that ‘= ANY’ syntax.

Advertisement

Answer

ANY (or its synonym SOME) is a syntax sugar for EXISTS with a simple correlation:

is the same as:

With the equality condition on a not-nullable field, it becomes similar to IN.

All major databases, including SQL Server, MySQL and PostgreSQL, support this keyword.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement