 <p>I think you are looking for something like this:</p> <pre><code>select TableA.idTableA, TableB.idTableB, case when EXISTS(select null from TableA TableA_1 where TableA_1.idTableA = TableA.idTableA and TableA_1.idTableB_FK = TableB.idTableB) then 'yes' else 'no' end as is_set from TableB left join TableA on TableB.idTableA_FK = TableA.idTableA </code></pre>