Search Postgresql Archives

Re: simple select question

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

 



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


[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