On 13. mars 2013, at 15:35, Ian Lawrence Barwick <barwick@gmail.com> wrote:
> -> "Is the integer value 1 contained in the specified result set,
> which happens to be an array (which is not comparable with an
> integer)?" (NO)
>
> select 1 = ANY ((SELECT ARRAY[1,2,3])::int[]);
> -> "Is the value one contained in an array of integers which is
> derived by converting a result set into an array?" (YES)
>
> Note:
>
> testdb=> SELECT array[1,2,3] = ANY (SELECT ARRAY[1,2,3]);
> ?column?
> ----------
> t
> (1 row)
>
> I hope that makes some kind of sense…
Right, "= ANY" could either match an array or a result set. I thought of it as only matching arrays, I've never used it
forsubqueries where I've always used IN, that's what had me confused. For most other operators a select enclosed in
parenthesiswill be converted to a single type, array or not, but in this case it's evaluated as a result set. That
clearsit up.
Thanks,
Michael