I have 3 tables
tblTeamMemberAreaCodes
============================
TeamMemberID | IntervalID | AreaCode
1 3 1
1 4 1
1 3 2
tblAreaCodes
===========================
AreaCode | AreaID
ABC 1
DEF 2
GHI 3
tblInterval
============================
IntervalID | Hours
1 1
2 2
3 3
4 4
How do I get all manipulations of AreaCodes and Intervals minus those that are in tblTeamMemberAreaCodes?
ie in this case I would be looking a result set like
TeamMemberID | IntervalID | AreaCode
NULL 1 1
NULL 1 2
NULL 1 3
NULL 1 4
NULL 2 1
NULL 2 2
NULL 2 3
NULL 2 4
NULL 3 2
NULL 3 3
NULL 3 4
NULL 4 2
NULL 4 3
NULL 4 4
ie every match up of Intervals and AreaCodes that are not in tblTeamMemberAreaCodes?
At the moment I have
SELECT NULL as 'TeamMemberID', IntervalID, AreaCode
FROM tblInterval a, tblAreaCodes b
WHERE a.IntervalID NOT IN (SELECT IntervalID FROM tblTeamMemberAreaCodes WHERE TeamMemberID = 1)
AND b.AreaCode IN (SELECT AreaCode FROM tblTeamMemberAreaCodes WHERE TeamMemberID = 1)
AND b.AreaID = 1
ORDER BY AreaCode, IntervalID
which is not working as the where clause is removing all IntervalID's which is incorrect. Any ideas?
tblTeamMemberAreaCodes
============================
TeamMemberID | IntervalID | AreaCode
1 3 1
1 4 1
1 3 2
tblAreaCodes
===========================
AreaCode | AreaID
ABC 1
DEF 2
GHI 3
tblInterval
============================
IntervalID | Hours
1 1
2 2
3 3
4 4
How do I get all manipulations of AreaCodes and Intervals minus those that are in tblTeamMemberAreaCodes?
ie in this case I would be looking a result set like
TeamMemberID | IntervalID | AreaCode
NULL 1 1
NULL 1 2
NULL 1 3
NULL 1 4
NULL 2 1
NULL 2 2
NULL 2 3
NULL 2 4
NULL 3 2
NULL 3 3
NULL 3 4
NULL 4 2
NULL 4 3
NULL 4 4
ie every match up of Intervals and AreaCodes that are not in tblTeamMemberAreaCodes?
At the moment I have
SELECT NULL as 'TeamMemberID', IntervalID, AreaCode
FROM tblInterval a, tblAreaCodes b
WHERE a.IntervalID NOT IN (SELECT IntervalID FROM tblTeamMemberAreaCodes WHERE TeamMemberID = 1)
AND b.AreaCode IN (SELECT AreaCode FROM tblTeamMemberAreaCodes WHERE TeamMemberID = 1)
AND b.AreaID = 1
ORDER BY AreaCode, IntervalID
which is not working as the where clause is removing all IntervalID's which is incorrect. Any ideas?