Matching a column against values in code

From: Tim <postgres(at)timkoop(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Matching a column against values in code
Date: 2005-02-11 16:12:52
Message-ID: 420CD984.8010608@timkoop.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello all.

I sometimes find myself needing an SQL query that will return all the
rows of a table in which one column equals any one of a list of values I
have in an array in code.

Does anyone know of a better way to do this than to loop through the
array and append an "or" comparison to the sql statement, like this?

sqlString = sqlString + " or this_column='" + arrayOfValues[i] +"' ";

If someone knows a command or function I can look up in the docs, just
say the name and I'll look there.

Thanks a lot everyone.

--
Tim

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message KÖPFERL Robert 2005-02-11 18:10:50 Constraint doesn't see a currently insertet record
Previous Message Richard Huxton 2005-02-11 09:22:08 Re: postgres 8 data directory other then default?