Array with Subselect / ANY - cast? - Mailing list pgsql-general

From Josh Trutwin
Subject Array with Subselect / ANY - cast?
Date
Msg-id 20070821124904.3768fb36@sinkhole.intrcomm.net
Whole thread Raw
Responses Re: Array with Subselect / ANY - cast?
Re: Array with Subselect / ANY - cast?
List pgsql-general
Hi - I have the following array field:

SELECT pb_ids FROM pb WHERE id = 123:

         pb_id
-----------------------
 {196,213,215,229,409}

These numbers map to a productid in tblproducts so I figured I could
do this:

SELECT *
  FROM tblproducts
 WHERE productid = ANY (
       SELECT pb_ids FROM pb WHERE id=123
 );

This complains: "ERROR:  operator does not exist: integer =
integer[]".

This doesn't seem much different than the example in the docs:

SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

If I do this:

SELECT *
  FROM tblproducts
 WHERE productid = ANY ('{196,213,215,229,409}'});

The query runs fine.

Any ideas on how to make this work?

Thanks!

Josh

P.S.  Postgres 8.1.9 on Linux

pgsql-general by date:

Previous
From: "Harald Armin Massa"
Date:
Subject: Re: Question on INDEX and SQL - stalling my database?
Next
From: "Pavel Stehule"
Date:
Subject: Re: Array with Subselect / ANY - cast?