Re: simple select question - Mailing list pgsql-general

From Richard Huxton
Subject Re: simple select question
Date
Msg-id 4663DC22.8030607@archonet.com
Whole thread Raw
In response to simple select question  ("Erol KAHRAMAN" <erol.kahraman@gmail.com>)
List pgsql-general
Erol KAHRAMAN wrote:
> hi guys,
>
> i am newbie in postgresql.  I need some help; i am trying to write like
> this:
>
> select * from TABLE where IN ('value1','valeue2',....)

You'll need to provide a column-name:
   ... WHERE mycolumn IN (...)

> but is it possible to give values from file.
>
> select * from TABLE where IN file

Not directly. You'd normally handle this in whatever language you are
using to query the database.

If you have a lot of values, you might find it useful to read them into
a temporary table.
CREATE TEMP TABLE my_values (...);
COPY my_values ... FROM <filename>;
ANALYSE my_values;
SELECT * FROM main_table JOIN my_values ON main_table_column =
my_values_column

Of course, that assumes you have your values one per line - see the
manuals for details of what COPY can handle.
--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Enrico Sirola
Date:
Subject: Re: table partitioning pl/pgsql helpers
Next
From: Ragnar
Date:
Subject: Re: simple select question