Select distinct A.col1, B.col2, col3
from A inner join B on A.id = B.id
and B.id in
(select distinct col2 from B where ..... )
Select distinct A.col1, B.col2, col3
from Select distinct A.col1, B.col2, col3
from A inner join B on A.id = B.id
and B.id in
(select distinct col2 from B where ..... )
Select distinct A.col1, B.col2, col3
from