pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedMatching a column against values in code
2+ messages / 2 participants
[nested] [flat]
* Matching a column against values in code
@ 2005-02-11 16:12 Tim <postgres@timkoop.com>
0 siblings, 1 reply; 2+ messages in thread
From: Tim @ 2005-02-11 16:12 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Matching a column against values in code
@ 2005-02-16 20:01 PFC <lists@boutiquenumerique.com>
parent: Tim <postgres@timkoop.com>
0 siblings, 0 replies; 2+ messages in thread
From: PFC @ 2005-02-16 20:01 UTC (permalink / raw)
To: Tim <postgres@timkoop.com>; pgsql-sql
This has been discussed a few hours ago on the mailing list on the
subject '[SQL] More efficient OR'
On Fri, 11 Feb 2005 10:12:52 -0600, Tim <postgres@timkoop.com> wrote:
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-02-16 20:01 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-11 16:12 Matching a column against values in code Tim <postgres@timkoop.com>
2005-02-16 20:01 ` PFC <lists@boutiquenumerique.com>
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