From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Thomas Good <tomg(at)sqlclinic(dot)net> |
Cc: | Postgres SQL List <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: JOIN condition confusion |
Date: | 2005-11-04 08:12:59 |
Message-ID: | 436B180B.8090908@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Kretschmer | 2005-11-04 12:48:52 | Re: serial in output |
Previous Message | oliverp21 | 2005-11-04 08:00:36 | unsubscribe |