pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim <postgres@timkoop.com>
To: pgsql-sql@postgresql.org
Subject: Matching a column against values in code
Date: Fri, 11 Feb 2005 10:12:52 -0600
Message-ID: <420CD984.8010608@timkoop.com> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <420CD984.8010608@timkoop.com>
Permalink:  ../420CD984.8010608@timkoop.com/
Also on:    postgresql.org/message-id/420CD984.8010608@timkoop.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgres@timkoop.com
  Subject: Re: Matching a column against values in code
  In-Reply-To: <420CD984.8010608@timkoop.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox