I have two tables A and B that contains the same Id (is not a primary key in the two tables) , and I would like to get only the data that exist in Table A .
Table A:
Id
1
2
555
6
Table B
Id
1
2
1
2
1
2
Query statement
select distinct o.Id
from Table A o,Table B ot
where o.isActive=1 and not(ot.Id=o.Id)
This will return the same data that exists in Table A, but the expected result should be :
Id
555
6
How can I get this works?