Re: How can we match a condition among 2 diff. tables?

From: "Joe Conway" <joseph(dot)conway(at)home(dot)com>
To: <bhuvansql(at)yahoo(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How can we match a condition among 2 diff. tables?
Date: 2001-07-13 18:57:19
Message-ID: 009a01c10bcd$a5383510$47d310ac@jecw2k1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> > Now, i need to get the details of all employees who did
> > receive NONE of the salesorders. ie.. i wish to select the
> > records of table 'employee' whose 'emp_id' are not
> > there in table 'salesorder'.
> >
> > I need to accompolish in a single query!

This should work:

select e.emp_id
from employee as e left join salesorder as s
on e.emp_id = s.emp_id
where s.emp_id is null;

-- Joe

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-07-13 19:00:27 Re: No subselects in constraint (bug?)
Previous Message Stephan Szabo 2001-07-13 18:25:45 Re: No subselects in constraint (bug?)