create table t1 (t1id integer not null primary key, t1text varchar(255)); create table t2 (t2id integer not null primary key, t2text varchar(255)); create table t3 (t3id integer not null primary key, t1id integer not null, t2id integer not null, t4id integer not null); insert into t1 values(1, 't1-1'); insert into t1 values(2, 't1-2'); insert into t1 values(3, 't1-3'); insert into t1 values(4, 't1-4'); insert into t2 values(1, 't2-1'); insert into t3 values(1, 1, 1, 0); select * from t1; select * from t2; select * from t3; SELECT t3.t1id, t1.t1text FROM t3, t1 WHERE t1.t1id = t3.t1id GROUP BY t3.t1id HAVING count(distinct t2id) != (select count(*) from t2);