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 2EE648BA165 for ; Fri, 11 Feb 2005 16:13:12 +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 05208-01 for ; Fri, 11 Feb 2005 16:12:57 +0000 (GMT) Received: from smtp2.wiband.com (smtp2.wiband.com [64.56.129.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2F2338B9B3B for ; Fri, 11 Feb 2005 16:12:55 +0000 (GMT) Received: from [192.168.2.12] [64.56.135.13] by smtp2.wiband.com with ESMTP (SMTPD32-7.07) id A985155F00EA; Fri, 11 Feb 2005 10:12:53 -0600 Message-ID: <420CD984.8010608@timkoop.com> Date: Fri, 11 Feb 2005 10:12:52 -0600 From: Tim User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Matching a column against values in code Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-RBL-Warning: SPAMHEADERS: This E-mail has headers consistent with spam [4000080e]. X-Declude-Sender: postgres@timkoop.com [192.168.2.12] X-Note: This E-mail was scanned by smtp2.wiband.com (abuse@wiband.com) for spam. X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200502/171 X-Sequence-Number: 20282 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