 <p>If I assume that the values are unique in each column, then the key idea is doing a join on the <em>second</em> column in the table followed by aggregation.</p> <p>A <code>having</code> clause can count the number of matches and be sure that it matches the expected number in the first table:</p> <pre><code>select t1.c1, t2.c1 from t1 join t2 on t1.c2 = t2.c2 group by t1.c1, t2.c1 having count(*) = (select count(*) from t1 tt1 where tt1.c1 = t1.c1); </code></pre>