From: | Thor Michael Støre <thormichael(at)gmail(dot)com> |
---|---|
To: | Ian Lawrence Barwick <barwick(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: SELECT 1 = ANY (SELECT ARRAY[1, 2, 3]) -> ERROR: operator does not exist: integer = integer[] ? |
Date: | 2013-03-13 14:58:53 |
Message-ID: | 9134971A-2F3B-4701-A500-65196723BC72@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 13. mars 2013, at 15:35, Ian Lawrence Barwick <barwick(at)gmail(dot)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 for subqueries where I've always used IN, that's what had me confused. For most other operators a select enclosed in parenthesis will be converted to a single type, array or not, but in this case it's evaluated as a result set. That clears it up.
Thanks,
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2013-03-13 15:24:53 | Re: table spaces |
Previous Message | Tom Lane | 2013-03-13 14:53:31 | Re: SELECT 1 = ANY (SELECT ARRAY[1, 2, 3]) -> ERROR: operator does not exist: integer = integer[] ? |