X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2D978B9C44 for ; Wed, 16 Feb 2005 20:12:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43502-09 for ; Wed, 16 Feb 2005 20:11:58 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id B8C648B9F85 for ; Wed, 16 Feb 2005 19:57:16 +0000 (GMT) Received: (qmail 20422 invoked from network); 16 Feb 2005 20:57:49 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 16 Feb 2005 20:57:49 +0100 To: Tim , pgsql-sql@postgresql.org Subject: Re: Matching a column against values in code References: <420CD984.8010608@timkoop.com> Message-ID: From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Wed, 16 Feb 2005 21:01:10 +0100 In-Reply-To: <420CD984.8010608@timkoop.com> User-Agent: Opera M2/7.54u1 (Linux, build 892) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/178 X-Sequence-Number: 20289 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 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 >