i have three table member (memberid,m_name,statusid,address,DOB,phone) booking (bookingid, memberid ,sessionid, cost) session(sessionid, activity,location)
(fk memberid, fk sessionid )BOOKING IS link with ( member pk )and (session pk)
session activity is like football,swimming,badminton,tennis i want to run the following query
find the name of all member who have booked any session for 'football', but not any session for 'swimming' during december 2009
sql
select DISTINCT Event1.m_name ,Event1.activity
FROM ( select mm.m_name,ss.activity,ss.sessionid,ss.s_date from member mm inner join booking bb on bb.memberid = mm.memberid inner join session ss on ss.sessionid = bb.sessionid where activity = 'football' )as Event1
INNER JOIN
( select mm.m_name ,ss.activity,ss.sessionid,ss.s_date from member mm inner join booking bb on bb.memberid = mm.memberid inner join session ss on ss.sessionid = bb.sessionid where mm.memberid not in ( select mm.memberid from member mm inner join booking bb on bb.bookingid = mm.memberid inner join session ss on bb.sessionid = ss.sessionid where ss.activity in ( 'swimming') )
) as Event2
on Event1.sessionid = Event2.sessionid
what im doing wrong it return me memeber who have book football and swmming.