Received: from hall.mail.mindspring.net (hall.mail.mindspring.net [207.69.200.60]) by postgresql.org (Postfix) with ESMTP id 37081475C3B for ; Mon, 1 Apr 2002 13:45:42 -0500 (EST) Received: from fw-6-e3.atl2.mindspring.net ([207.69.162.124] helo=hbg-ntd-467b.mindspring.com) by hall.mail.mindspring.net with esmtp (Exim 3.33 #1) id 16s5uE-0002mk-00 for pgsql-sql@postgresql.org; Mon, 01 Apr 2002 12:47:47 -0500 Message-Id: <5.1.0.14.2.20020401124436.02aaf1c0@proxy> X-Sender: bcdoyle@proxy X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Mon, 01 Apr 2002 12:47:30 -0500 To: pgsql-sql@postgresql.org From: "Brian C. Doyle" Subject: Sub-Select in CASE Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Archive-Number: 200204/6 X-Sequence-Number: 7271 Hello all, I am trying to run a query that checks to see if a mail box exist in a db. If the mail box does not exist i need it to return another address. Currently I am working with : SELECT CASE WHEN alias.mbox='brian' THEN alias.email_add ELSE (SELECT alias.email_add WHERE alias.mbox='*' AND alias.domain='domain.com) END WHERE alias.domain='domain.com' and alias.mbox='brian'; I am not even sure if Case is the best choice. More background info on it, this is for and db that EXIM enter acts with and i want to be able to setup a default alias.