I have 2 Tables. I want to extract every TB2_ID in Table 2 for which certain conditions are fulfilled in Table 1. So in the case below, we would extract ‘2’ since it is FULLY fulfilled by both ID ‘1’ and ’15’ in Table 1. TB2_ID ‘4’ would not be extracted since there is no TB1_ID that FULLY fulfills it (i.e. if TB1_ID ’16’ also had a condition of 10, then TB2_ID ‘4’ would be extracted). I am using Oracle SQL 10g.
Table 1 looks like:
TB1_ID | Condition
______________________
1 | 10
1 | 11
1 | 12
5 | 10
5 | 11
15 | 10
15 | 11
15 | 12
16 | 11
16 | 14
Table 2 looks like:
TB2_ID | Condition
_______________________
2 | 10
2 | 11
2 | 12
4 | 10
4 | 14
This can most simply specified as: Find any TB2_ID that is not satisfied in table 1: