Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id E72629FB273 for ; Thu, 11 Jan 2007 17:37:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 54643-05 for ; Thu, 11 Jan 2007 17:36:50 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from bay0-omc1-s41.bay0.hotmail.com (bay0-omc1-s41.bay0.hotmail.com [65.54.246.113]) by postgresql.org (Postfix) with ESMTP id 703A09FA19A for ; Thu, 11 Jan 2007 17:36:53 -0400 (AST) Received: from hotmail.com ([64.4.54.104]) by bay0-omc1-s41.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Thu, 11 Jan 2007 13:34:54 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 11 Jan 2007 13:34:53 -0800 Message-ID: Received: from 85.101.172.197 by by20fd.bay20.hotmail.msn.com with HTTP; Thu, 11 Jan 2007 21:34:50 GMT X-Originating-IP: [85.101.172.197] X-Originating-Email: [definite_ocean@hotmail.com] X-Sender: definite_ocean@hotmail.com From: "devil live" To: pgsql-sql@postgresql.org Subject: Conditional SQL Query Date: Thu, 11 Jan 2007 21:34:50 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 11 Jan 2007 21:34:53.0709 (UTC) FILETIME=[54E0ABD0:01C735C8] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.777 tagged_above=0 required=5 tests=AWL, BAYES_50, MSGID_FROM_MTA_HEADER X-Spam-Level: X-Archive-Number: 200701/34 X-Sequence-Number: 27186 I want to write sql statement about product, product_tree_special, product_tree_template product has product_code varchar(20) PRIMARY KEY, product_name varchar(20) product_tree_template has product_code varchar(20) PK, stock_code_to_make_product(20) PK, amout float4 product_tree_spcial has production_no serial, product_code varchar(20) PK, stock_code_to_make_product(20) PK, amout float4 NOW : product_tree_template table is the default table for production ingredients of the PRODUCT but sometimes my customer using special product_tree table for some production_no how can I write a query to get right ingredients of a product basis on production_no field such as; first check production_no if product_tree_special table if not found then look at template table... What are your suggestions? PS: I do not wanna write PL functions for this... Thanks _________________________________________________________________ Hava durumunu bizden ögrenin ve evden öyle çikin! http://www.msn.com.tr/havadurumu/