Re: Using Query Result in WHERE Clause

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Using Query Result in WHERE Clause
Date: 2006-06-05 11:10:07
Message-ID: 20060605111007.GA4832@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Jun 02, 2006 at 01:06:40PM -0700, operationsengineer1(at)yahoo(dot)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(at)crankycanuck(dot)ca
If they don't do anything, we don't need their acronym.
--Josh Hamilton, on the US FEMA

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bricklen Anderson 2006-06-05 14:49:02 Re: Get max value from an comma separated string
Previous Message Bruno Wolff III 2006-06-05 02:12:39 Re: Get max value from an comma separated string