I have 4 tables Tab1 -- columns: id Tab2 -- columns: id, Tab1Id Tab3 -- columns: id, Tab2Id Tab4 -- columns: id, Tab3Id
There could be multiple rows of same id from another table. Eg: same Tab1Id can be present multiple times in Tab2, same Tab3Id can be present in Tab4 multiple times etc
I want to now get all Tab1 records, that dont have any rows in Tab4 through the connected tables.
I am able to get all the Tab3 that done have entry in Tab4, but then how do I put them in a group to know what entries from Tab1 have no entries in Tab4.
Tab1
+----+
| id |
+----+
| 1 |
+----+
| 2 |
+----+
Tab2
+----+--------+
| id | Tab1Id |
+----+--------+
| 10 | 1 |
+----+--------+
| 20 | 1 |
+----+--------+
| 30 | 2 |
+----+--------+
| 40 | 2 |
+----+--------+
Tab3
+----+--------+
| id | Tab2Id |
+----+--------+
| 100 | 10 |
+----+--------+
| 200 | 10 |
+----+--------+
| 300 | 20 |
+----+--------+
Tab4
+------+--------+
| id | Tab3Id |
+------+--------+
| 1000 | 100 |
So with my query I only want the id 2 from Tab1, as none of the corresponding entries for this id exist in Tab4