Обсуждение: select ... where ... in - headache

Поиск
Список
Период
Сортировка

select ... where ... in - headache

От
"Ian W Roberts"
Дата:
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




Re: select ... where ... in - headache

От
Scott Lamb
Дата:
Ian W Roberts wrote:

> Can someone help me?
>
> I'm using Pg to access a postgres database for a web application.

This doesn't directly answer your question, but why are you using Pg and
not the DBD::Pg driver for DBI? The DBI interface is common between
database drivers, much more widely used, and probably much more complete.

Scott