pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-sql@postgresql.org
Subject: Re: Using Query Result in WHERE Clause
Date: Mon, 5 Jun 2006 07:10:07 -0400
Message-ID: <20060605111007.GA4832@phlogiston.dyndns.org> (raw)
In-Reply-To: <20060602200640.91950.qmail@web33304.mail.mud.yahoo.com>
References: <20060602200640.91950.qmail@web33304.mail.mud.yahoo.com>

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



view thread (2+ messages)

Message-ID: <20060605111007.GA4832@phlogiston.dyndns.org>
Permalink:  ../20060605111007.GA4832@phlogiston.dyndns.org/
Also on:    postgresql.org/message-id/20060605111007.GA4832@phlogiston.dyndns.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ajs@crankycanuck.ca
  Subject: Re: Using Query Result in WHERE Clause
  In-Reply-To: <20060605111007.GA4832@phlogiston.dyndns.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox