X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6B3B19FA2DB for ; Mon, 5 Jun 2006 08:10:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 24604-02 for ; Mon, 5 Jun 2006 08:10:18 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id E85F59FA111 for ; Mon, 5 Jun 2006 08:10:18 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1FnD29-0000mI-L0 for pgsql-sql@postgresql.org; Mon, 05 Jun 2006 07:14:09 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id A3CB03FAF; Mon, 5 Jun 2006 07:10:07 -0400 (EDT) Date: Mon, 5 Jun 2006 07:10:07 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Using Query Result in WHERE Clause Message-ID: <20060605111007.GA4832@phlogiston.dyndns.org> References: <20060602200640.91950.qmail@web33304.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060602200640.91950.qmail@web33304.mail.mud.yahoo.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/52 X-Sequence-Number: 25288 On Fri, Jun 02, 2006 at 01:06:40PM -0700, operationsengineer1@yahoo.com wrote: > hi all, > > SUMMARY: > > i want to replace > > AND t_inspect.inspect_pass = 'f' > > with a complex query that yields the same result. the > complex query is in the form of... [snip] But your complex query isn't in the form where anything will come out "= 'f'". You have too many columns in the SELECT. What you prabably need to do is rewrite it as a subquery in the FROM clause, alias it as (say) alias_t_inspect, and then use your condition to get you what you want. I won't warrant what the performance will be, however. A -- Andrew Sullivan | ajs@crankycanuck.ca If they don't do anything, we don't need their acronym. --Josh Hamilton, on the US FEMA