From: Richard Huxton <dev@archonet.com>
To: Thomas Good <tomg@sqlclinic.net>
Cc: Postgres SQL List <pgsql-sql@postgresql.org>
Subject: Re: JOIN condition confusion
Date: Fri, 04 Nov 2005 08:12:59 +0000
Message-ID: <436B180B.8090908@archonet.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0510311325420.17323-100000@q8.nrnet.org>
References: <Pine.LNX.4.44.0510311325420.17323-100000@q8.nrnet.org>
Thomas Good wrote:
> Hi,
>
> I am wondering if there is a way to set conditions on a left joined
> table without hosing the join altogether:
>
> query = qq |SELECT p.*, a.user_id
> FROM patient_dosing p
> LEFT JOIN patient_assignment a
> ON p.patient_id = a.patient_id
> WHERE p.dose_type = 'Missed (AWOL)'
> AND (p.dose_date >= $start_date AND p.dose_date <= $end_date)
> -- the next two conditions hose the left join
> -- AND a.end_date IS NULL
> -- AND lower(a.assign_type) = 'primary'
> ORDER BY a.user_id, p.patient_id| if ($dbtype ne "oracle");
What do you want to happen? What do you mean by a left-join where the
right-hand side has assign_type='primary'?
--
Richard Huxton
Archonet Ltd
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: dev@archonet.com, tomg@sqlclinic.net
Subject: Re: JOIN condition confusion
In-Reply-To: <436B180B.8090908@archonet.com>
* 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