On Tue, Jan 21, 2003 at 08:43:29AM -0800, Josh L Bernardini wrote:
> 
> I have three tables, people, events and epeople. epeople includes a person
> id and an event id and works as a list of people attending events in the
> database.
> 
> The following query returns a list of all the people participating in a
> particular event
> given an event id.
> 
> select people.id as pid, concat(lastname, ", ", firstname) as name from
> events
>       left join epeople on events.id=epeople.eid
>       left join people on epeople.pid=people.id
>             where events.id=2;
> 
> How could I get a list of all the people not participating?
>       thought I would add to the where clause with:
>             and people.id is null;
> 
> but that returns an empty set.

Right. Presumably, there's no entry in your join table to link a 
person to an event that they're not attending.

I've got a entry in the MySQL SQL section of my website called 
"Whether a row on one side of a many-to-many join is linked to 
a given row on the other side" that has a solution.
http://users.starpower.net/rjhalljr/Serve

Bob Hall

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to