I have two tables which look like this:
T1: ID | Date | Hour | Interval
T2: ID | Date | Hour
I basically need to join these tables when their IDs, dates, and hours match. However, I only want to return the results from table 1 that do not match up with the results in table 2.
I know this seems simple, but where I'm stuck is the fact that there are multiple rows in table 1 that match up with table 2 (there are multiple intervals for any given hour). I need to return all of these intervals so long as they do not fall within the same hour period in table 2.
Example data:
T1: 1 | 1/1/2011 | 1 | 1
1 | 1/1/2011 | 1 | 2
1 | 1/1/2011 | 2 | 1
1 | 1/1/2011 | 2 | 2
T2: 1 | 1/1/2011 | 1
My expected result set for this would be the last two rows from T1
. Can anyone point me on the right track?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…