On May 1, 2006, at 3:32 , Jim Fitzgerald wrote:
I have two tables, one of them has names of people and an associated
integer ID. The other table is a list of the people (from the
first table)
by their ID number that have signed up for a class. How would I
write a
query that would list all the people from the first table that do
not have
any entries in the second table? Basically, I want a listing of
all my
people who have not signed up for the class.
What you want is sometimes called a semi-difference. Here's how I'd
do it:
select person_id, person_name
from persons
natural join (
select person_id
from persons
except
select person_id
from class_signups
) not_yet_signed_up
where persons is your first table and class_signups is your second
table.
Hope this helps!
Michael Glaesemann
grzm seespotcode net