Here is one way to do this:
SELECT group_id FROM table WHERE group_id IN (SELECT group_id FROM table WHERE domain_id in (2124, 2124)) GROUP BY group_id HAVING count(group_id) = 2;
The advantage of this approach is that the two domain_ids do not have to be sequential, as in one of the other answers.
Using your data in sqlite3, you will get:
sqlite> create table t (a int, b int);
sqlite> .import data t
sqlite> SELECT a FROM t WHERE a IN (SELECT a FROM t WHERE b in (2124, 2124)) GROUP BY a HAVING count(a) = 2;
a
112
source
share