select * from tab1 where id in CASE WHEN EXISTS (select null from tab2) THEN (select id from tab2) ELSE id END
THEN (select id from tab2) ELSE id END
select t1.id, t1.name from t1 minus select t1.id,t1.name from t1 inner join t2 on t1.id<>t2.id
select * from tab1 where id in CASE WHEN EXISTS (select null from tab2) THEN (select id from tab2 where id = tab1.id) ELSE id END
select * from tab1 where ((select count(*) from tab2) =0 or id in (select id from tab2))
THEN (select id from tab2 where id = tab1.id) ELSE
SELECT t.* FROM t, (SELECT * FROM t2 UNION ALL SELECT null FROM DUAL) t2 WHERE t.ID = CASE WHEN exists (SELECT null FROM t2) THEN t2.ID ELSE t.ID END;