Re: How would I write this query...
От | Michael Glaesemann |
---|---|
Тема | Re: How would I write this query... |
Дата | |
Msg-id | 5C90753A-67A6-4C69-9D07-32C5040D0690@seespotcode.net обсуждение исходный текст |
Ответ на | How would I write this query... ("Jim Fitzgerald" <jfitz@spacelink.com>) |
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: