Doing a join to find out what doesnt match
Posted: Sun Aug 16, 2009 8:11 pm
Hi everyone,
I have 2 table,1 called events and the other called attendence. events has an event_id and other fields. attendence has member_id and event_id. I am looking to write a query which will select me all entries in the events table which do not have a event_id/member_id combination in the attendence table.
Thank you
So far I have tried:
the problem is however, when the user does not have any entries in the attendence table, no events show using the query. If I do remove the where clause, all i get is a repetitive list of all the events available
I have 2 table,1 called events and the other called attendence. events has an event_id and other fields. attendence has member_id and event_id. I am looking to write a query which will select me all entries in the events table which do not have a event_id/member_id combination in the attendence table.
Thank you
So far I have tried:
Code: Select all
SELECT events.event_name,events.event_id from events LEFT JOIN attendence on events.event_id != attendence.event_id where attendence.member_id = 27