X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6236AD1BA5E for ; Fri, 31 Oct 2003 13:31:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88909-10 for ; Fri, 31 Oct 2003 09:30:32 -0400 (AST) Received: from sam.on-net.net (mail.on-net.net [204.117.190.8]) by svr1.postgresql.org (Postfix) with ESMTP id 02E53D1B8AC for ; Fri, 31 Oct 2003 09:30:29 -0400 (AST) Received: from [206.229.85.132] (edison.base2inc.com [206.229.85.132]) (authenticated bits=0) by sam.on-net.net (8.12.10/8.12.10) with ESMTP id h9VDUWSS019896 for ; Fri, 31 Oct 2003 08:30:33 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v606) Content-Transfer-Encoding: 7bit Message-Id: <5D07F76A-0BA6-11D8-A615-000A95A83378@base2inc.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: pgsql-sql@postgresql.org From: Frank Morton Subject: conditional query? Date: Fri, 31 Oct 2003 08:30:16 -0500 X-Mailer: Apple Mail (2.606) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/411 X-Sequence-Number: 15811 I have a table called a "profile" that has company addresses as well as individual contact information. Simpifying: id (the primary key) parentId (any profile can have a parent ie, contact parent is a company) address (for this example, will just have one piece of the address) useParentAddress If "useParentAddress"=="Y", that means that the parent address of this person should really be used for mailings. If == "N" then the address with that profile is the right one to use. Is there any way to do a single select to get a single "address" back that is the right one depending on the value of "useParentAddress" field? Also want to make this sql as portable as possible. Will appreciate any ideas.