If I interpret your question correctly: *"Pick all rows where `a` has one of two given values, and `b` only exists in combination with one of them."* You can use any of the standard techniques laid out in the referenced answer. - http://dba.stackexchange.com/questions/16650/help-with-this-select-in-the-same-table/16651#16651 Just restrict your base table to the two given `a`. For instance SELECT * FROM tbl t1 WHERE a IN (1,2) AND NOT EXISTS ( SELECT 1 FROM tbl t2 WHERE a IN (1,2) AND t2.b = t1.b AND t2.a <> t1.a ); [**SQL Fiddle**][1] This also works with duplicates on `(a,b)`. Multiple identical rows would be returned. [1]: http://sqlfiddle.com/#!15/efbc3/1