The table 1 is as follows,
| ID | FK1_ID | FK2_ID |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 1 | 2 |
| 3 | 1 | 3 |
The table with FK2 is as follows,
| ID | Type | Status |
|---|---|---|
| 1 | Type1 | True |
| 2 | Type2 | True |
| 3 | Type1 | False |
The FK2_ID column is the ID column of table 2.
The expected result is, for any FK1_ID(which I have as a list of IDs), need to check all its FK2 entries in the 2nd table of Type1 and status True.
For example: Here, I want to return YES, if all the Type1 entries are True for the specific FK1_ID. Else NO.
So, for FK1_ID with 1, the FK2 table has 3 records. Of which Type1 has 2 records. I should return YES, if both Type1 records are True, else NO.
I want accomplish this using SQL. Any help is appreciated?