I have two tables, each with three boolean (ms-access "Yes/No") columns.
Table 1: A1, B1, C1
Table 2: A2, B2, C2
I would like the rows from Table 2 given a specific row from Table 1 that satisfy the following conditions:
If A1 is true then only rows where A2 is true, if A1 is false then rows where A2 is true or false. If B1 is true then only rows where B2 is true, if B1 is false then rows where B2 is true or false. If C1 is true then only rows where C2 is true, if C1 is false then rows where C2 is true or false.
Example One
A, B, C
Table 1: 0, 1, 0 (selected row)
Table 2: 1, 0, 0
0, 1, 0 (in return set)
1, 1, 0 (in return set)
0, 0, 1
1, 0, 1
0, 1, 1 (in return set)
1, 1, 1 (in return set)
Example Two
A, B, C
Table 1: 0, 0, 1 (selected row)
Table 2: 1, 0, 0
0, 1, 0
1, 1, 0
0, 0, 1 (in return set)
1, 0, 1 (in return set)
0, 1, 1 (in return set)
1, 1, 1 (in return set)
How can I best accomplish this?
For example, this does not work:
SELECT vw_fbScheduleFull.LocationName, vw_fbScheduleFull.FieldName, vw_fbScheduleFull.Description, vw_fbScheduleFull.StartTime,
vw_fbScheduleFull.EndTime, vw_fbScheduleFull.LowerDivision, vw_fbScheduleFull.UpperDivision, vw_fbScheduleFull.SeniorDivision
FROM (vw_fbScheduleFull INNER JOIN
fbDivision ON vw_fbScheduleFull.LowerDivision = fbDivision.LowerDivision AND fbDivision.LowerDivision = 1 OR
vw_fbScheduleFull.UpperDivision = fbDivision.UpperDivision AND fbDivision.UpperDivision = 1 OR
vw_fbScheduleFull.SeniorDivision = fbDivision.SeniorDivision AND fbDivision.SeniorDivision = 1)
WHERE (vw_fbScheduleFull.PracticeDate = ?) AND (vw_fbScheduleFull.Locked IS NULL) AND (fbDivision.DivisionName = ?)
ORDER BY vw_fbScheduleFull.LocationName, vw_fbScheduleFull.FieldName, vw_fbScheduleFull.StartTime