Search Postgresql Archives

Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13. mars 2013, at 15:35, Ian Lawrence Barwick <barwick@xxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux