Array with Subselect / ANY - cast?

From: Josh Trutwin <josh(at)trutwins(dot)homeip(dot)net>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Array with Subselect / ANY - cast?
Date: 2007-08-21 17:49:04
Message-ID: 20070821124904.3768fb36@sinkhole.intrcomm.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2007-08-21 18:15:59 Re: Array with Subselect / ANY - cast?
Previous Message Harald Armin Massa 2007-08-21 16:26:58 Re: Question on INDEX and SQL - stalling my database?