X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D237552CAC for ; Sat, 20 Aug 2005 08:25:21 -0300 (ADT) 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 99252-10 for ; Sat, 20 Aug 2005 11:25:18 +0000 (GMT) Received: from web52714.mail.yahoo.com (web52714.mail.yahoo.com [206.190.48.237]) by svr1.postgresql.org (Postfix) with SMTP id E942F52E1C for ; Sat, 20 Aug 2005 08:25:14 -0300 (ADT) Received: (qmail 43691 invoked by uid 60001); 20 Aug 2005 11:25:16 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; h=Message-ID:Received:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=h5tOIpu3b957T9QF9CAAwuBp+RVpIRyseOzr45f38auH9t4/zlZwdu48ZbjSMBFJiDgG/NhIzmuJrh5SRYsQVUR7StV4lJomsu8QpmmbPJ2/VbWqeBlq2BPEPuRjt93r4CKQWGG1fV8NQfhTgkNUka/eb/shZ6rjbbfq6/8Nwso= ; Message-ID: <20050820112516.43689.qmail@web52714.mail.yahoo.com> Received: from [200.141.110.157] by web52714.mail.yahoo.com via HTTP; Sat, 20 Aug 2005 11:25:16 GMT Date: Sat, 20 Aug 2005 11:25:16 +0000 (GMT) From: Halley Pacheco de Oliveira Subject: Re: SQL CASE Statements To: pgsql-sql@postgresql.org Cc: lvaningen@esncc.com MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.153 required=5 tests=[AWL=-0.454, DNS_FROM_RFC_ABUSE=0.374, RCVD_IN_NJABL_PROXY=1.026, UPPERCASE_25_50=0.207] X-Spam-Level: * X-Archive-Number: 200508/173 X-Sequence-Number: 22401 > Has anybody done this? If so, can you send me a sample? CREATE TEMPORARY TABLE fruits (id SERIAL, name TEXT); INSERT INTO fruits VALUES (DEFAULT, 'banana'); INSERT INTO fruits VALUES (DEFAULT, 'apple'); CREATE TEMPORARY TABLE food (id SERIAL, name TEXT); INSERT INTO food VALUES (DEFAULT, 'apple'); INSERT INTO food VALUES (DEFAULT, 'spinach'); SELECT name, CASE WHEN name = ANY (SELECT name FROM fruits) THEN 'yes' ELSE 'no' END AS fruit FROM food; name | fruit ---------+------- apple | yes spinach | no (2 lines) __________________________________________________ Converse com seus amigos em tempo real com o Yahoo! Messenger http://br.download.yahoo.com/messenger/