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 37ECE564DA for ; Tue, 15 Mar 2005 08:19: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 46164-07 for ; Tue, 15 Mar 2005 08:19:09 +0000 (GMT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id E7F85564C8 for ; Tue, 15 Mar 2005 08:19:02 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 4.42) id 1DB7EL-000AD2-HI; Tue, 15 Mar 2005 08:16:45 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 7AE8A17604; Tue, 15 Mar 2005 08:18:59 +0000 (GMT) Message-ID: <42369A73.3050502@archonet.com> Date: Tue, 15 Mar 2005 08:18:59 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: lucap@personainternet.com Cc: pgsql-sql@postgresql.org Subject: Re: select multiple immediate values, but in multiple rows References: <200503142318.27510.lucap@shaw.ca> In-Reply-To: <200503142318.27510.lucap@shaw.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/210 X-Sequence-Number: 20689 Luca Pireddu wrote: > Hello all. I'd like to write a query does a set subtraction A - B, but A is > is a set of constants that I need to provide in the query as immediate > values. I thought of something like > > select a from (1,2,3.4) > except > select col_name from table; richardh=> SELECT * FROM foo; a --- 1 2 3 (3 rows) richardh=> SELECT * FROM foo WHERE a NOT IN (1,2); a --- 3 (1 row) Run some tests with nulls in the column and the constant list too so you understand what happens in those cases. -- Richard Huxton Archonet Ltd