I've two tables: table 1
with a column of parent ID's (P-id), and table 2
with two columns: P_id and C-id(Child ID's ).
In table 2 for each child the parent is shown, but the child can have more then one parent and vice versa.(many to many). Now I need to find all P-id's which presents parents who do not have parents themselves based on this P-id|C_id relationship. The difficulty in my opinion is that there is no direct info about the parent level.
P_id
------
1
2
3
C_id
------
1
2
3
4
5
P_id C_id
-----------
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 1
3 5
3 3
The answer should be P_id 2 and 3