I have following requirement:
main_set table has all the ids,
user_input table has all user entered ids.
I want result of ids that exist in user_input table. If nothing in user_input table then I want all the ids from main_input table.
Here's what I have so far:
create table main_set as select 1 id from dual union all select 2 from dual union all select 3 from dual create table user_input as select 1 id from dual union all select 2 from dual select * from main_set ms where exists (select null from user_input ui where ui.id = ms.id)