drop table digits; drop table odd; create table digits (d int); insert into digits values 1, 2, 3, 4, 5, 6, 7, 8, 9, 0; create table odd (o int); insert into odd values 1, 3, 5, 7, 9; select distinct temp_t0.d from (select d from digits where d > 3) temp_t0, (select o from odd) temp_t1, odd temp_t4, (select o from odd) temp_t3 where temp_t0.d = temp_t1.o and temp_t0.d = temp_t3.o and temp_t0.d in (select o from odd where o = temp_t1.o) and exists ( select d from digits where d = temp_t0.d) -- Will HANG (loop indefinitely) here... ;