select ... where ... in - headache - Mailing list pgsql-general

From Ian W Roberts
Subject select ... where ... in - headache
Date
Msg-id 3de9c827@kastagir.senet.com.au
Whole thread Raw
Responses Re: select ... where ... in - headache  (Scott Lamb <slamb@slamb.org>)
List pgsql-general
Can someone help me?

I'm using Pg to access a postgres database for a web application. I have an
apparently robust database connection and have been using Pg::doQuery to
return a list-of-lists of the data
-all working OK.

However, I've been trying to process the following command without success:

select <some fields>  from table1 where keyfield in (select keyfield from
table2);

This exact command returns the correct data when entered at the command
prompt in my POSTGRESQL interactive sql monitor but consitently returns no
data via the Pg::doQuery.

If I replace the nested select statement with a list of values then the
command works correctly, eg:

select <some fields> from table1 where keyfield in (15,17) ;

Is there some reason why the nested statement doesn't/cannot work with Pg?

How can I achieve the same result?

TIA

ian


Software versions:

PostgreSQL 6.5.3 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66
Perl 5.005, patch 03




pgsql-general by date:

Previous
From: "j.random.programmer"
Date:
Subject: Postgresql -- initial impressions and comments
Next
From: "Wynn, Robin"
Date:
Subject: Backend message type 0x50 arrived while idle