left join syntax

From: "Haywood J'Bleauxmie" <hj(at)fc3(dot)outerscape(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: left join syntax
Date: 2001-05-08 07:36:14
Message-ID: fc.009863ef00002846009863ef00002846.284b@fc3.outerscape.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a database that tracks work orders. Each order tracks two entries
from the employees table; the employee ID of the person assigned to the
work order and the ID of the person who completed the order. Each work
order may have one, both, or neither field filled in. As such, I need to
left join the employee table to the work order table, but I cannot figure
out the syntax for the double-join. As independent selects, I can do the
join:

SELECT o.ordr_id, a.last_name
FROM ordr o left join employee a on o.assigned_id = a.emp_id;

SELECT o.ordr_id, c.last_name
FROM ordr o left join employee c on o.completion_id = c.emp_id;

But I would like to have the whole thing in a single SELECT. Can you help
me out?

------------------------------------------------
Haywood J'listzen

Browse pgsql-sql by date

  From Date Subject
Next Message Oliver Elphick 2001-05-08 11:29:08 Re: left join syntax
Previous Message Tom Lane 2001-05-08 04:55:59 Re: RI permission problem