Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tp2DP-0001DC-0N for pgsql-sql@arkaria.postgresql.org; Sat, 29 Dec 2012 19:37:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tp2DO-0002RJ-Dv for pgsql-sql@arkaria.postgresql.org; Sat, 29 Dec 2012 19:37:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tp2DN-0002QP-5I for pgsql-sql@postgresql.org; Sat, 29 Dec 2012 19:37:01 +0000 Received: from forward6.mail.yandex.net ([2a02:6b8:0:202::7]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tp2DL-0003jV-MI for pgsql-sql@postgresql.org; Sat, 29 Dec 2012 19:37:00 +0000 Received: from web15e.yandex.ru (web15e.yandex.ru [77.88.60.18]) by forward6.mail.yandex.net (Yandex) with ESMTP id 6756B11218BA; Sat, 29 Dec 2012 23:36:57 +0400 (MSK) Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by web15e.yandex.ru (Yandex) with ESMTP id 1CE3D11A8001; Sat, 29 Dec 2012 23:36:57 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1356809817; bh=45c8ekuItPxmvmiUezj4JhIA6HhmWczjcRiH99aHrYo=; h=From:To:Cc:In-Reply-To:References:Subject:Date; b=JQ7fI+XB7uVjxmmmUkED9yXV86K9Fd9qLtuKqu6ZIRzDX4UMJmHUyNJf1084qIJeA 6Nd9G2MkMkQVPyC6jx5rF9xjwkCOezwy7fic+1XqL7dFrplbA5ZTG7p/c1i8Cd1x3e AObOImwHyIHIsHM/RQ6OCtyLcl6/Peav7dJFmgII= Received: from 93-81-37-12.broadband.corbina.ru (93-81-37-12.broadband.corbina.ru [93.81.37.12]) by web15e.yandex.ru with HTTP; Sat, 29 Dec 2012 23:36:56 +0400 From: msi77 To: JORGE MALDONADO Cc: pgsql-sql@postgresql.org In-Reply-To: References: Subject: Re: Query execution based on a condition MIME-Version: 1.0 Message-Id: <2795691356809816@web15e.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sat, 29 Dec 2012 23:36:56 +0400 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Pg-Spam-Score: -1.8 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Change the conditions of other 3 queries, so those shall give empty row sets depending on your value. 29.12.2012, 23:06, "JORGE MALDONADO" : > I have a query similar to the one shown below but, depending on the value of a field, only the first SELECT statement shoud execute and the other 3 should be ignored. Is there a way to achieve this situation? > > SELECT fields FROM tblTable WHERE condition > UNION > > SELECT fields FROM tblTable WHERE condition > > UNION > > SELECT fields FROM tblTable WHERE condition > UNION > > SELECT fields FROM tblTable WHERE condition > > Respectfully, > Jorge Maldonado -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql