pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: jtx <jtx@hatesville.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: join/case
Date: Sat, 31 May 2003 08:08:31 -0500
Message-ID: <20030531130831.GA31995@wolff.to> (raw)
In-Reply-To: <000001c326ff$b9993f50$c733a8c0@slappy>
References: <000001c326ff$b9993f50$c733a8c0@slappy>

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';



view thread (4+ messages)

Message-ID: <20030531130831.GA31995@wolff.to>
Permalink:  ../20030531130831.GA31995@wolff.to/
Also on:    postgresql.org/message-id/20030531130831.GA31995@wolff.to

 · 

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: bruno@wolff.to, jtx@hatesville.com
  Subject: Re: join/case
  In-Reply-To: <20030531130831.GA31995@wolff.to>

* 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