Re: join/case - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: join/case
Date
Msg-id 20030531130831.GA31995@wolff.to
Whole thread Raw
In response to join/case  ("jtx" <jtx@hatesville.com>)
List pgsql-sql
On Fri, May 30, 2003 at 16:03:44 -0700, jtx <jtx@hatesville.com> wrote:
> Basically, I have something like this:
> 
> Select o.id,o.num_purch,o.program from orders o left join lists l on
> l.order_id=o.id where o.uid=1 and o.status!='closed'
> 
> However, I want to throw an extra conditional in there that says if
> l.status='processing', then don't return anything.  So, I tried:

The straight forward way to do this is do just do what you described.
Make the join a subselect (keeping l.status) and then select from that
where status <> 'processing. The result looks like:

select id, num_purch, program from   (select o.id,o.num_purch,o.program,l.status     from orders o left join lists l on
l.order_id=o.id    where o.uid=1 and o.status!='closed') as j where   status <> 'processing';
 


pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [PERFORM] [GENERAL] Yet Another (Simple) Case of Index not used
Next
From: DIB Walid
Date:
Subject: postgresql and the industry