Search Postgresql Archives

Array with Subselect / ANY - cast?

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

 



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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[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