I have 2 tables :
Table1
Parent(varchar) Child (varchar)
Table2
C1(varchar) PC (varchar)
Sample data:
Requirement - I need Table2.C1 values for which column Table2.PC = Table1.Child , but Child values must be different from Table1.Parent's values..
I'm using below query in mysql:
select distinct(C1),Child,PC
from Table2 inner join Table1
on Table2.PC=Table1.Child
where Table1.Child not in (select Parent from Table1);
It is giving empty set, but there are values in Child which is same as in PC, but not in Parent....
Where I'm getting wrong?