Difference between "in (...)" and "= any(...)" queries when using arrays

From: "Francisco Figueiredo Jr(dot)" <francisco(at)npgsql(dot)org>
To: PgSql General <pgsql-general(at)postgresql(dot)org>
Subject: Difference between "in (...)" and "= any(...)" queries when using arrays
Date: 2009-05-12 05:09:08
Message-ID: 438d02260905112209s74a71e9btd896387144077616@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all!

I was playing with "in (...)" and "= any (...)" queries and found a
difference between them and I wonder:

why this works:

select * from table_of_integers where integer_column = any (array[5,6]);

and this doesn't:

select * from table_of_integers where integer_column in (array[5,6]);

Although documentation says:

9.20.4. ANY/SOME

[...]
SOME is a synonym for ANY. IN is equivalent to = ANY.
[...]

I thought that if IN is equivalent to = any, both queries above should work.

Am I missing something?

Thanks in advance.

--
Regards,

Francisco Figueiredo Jr.
Npgsql Lead Developer
http://www.npgsql.org
http://fxjr.blogspot.com
http://twitter.com/franciscojunior

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ow Mun Heng 2009-05-12 05:23:14 Putting many related fields as an array
Previous Message Andrew Maclean 2009-05-12 01:17:36 Re: Getting a list of encodings.