I'd really like know if it's possible to do a select statement, which returns exactly same records, that we put into in clause?
Sample:
select * from table
where table_id in (1, 2, 3, 666);
This table for an example has only id-s from 1 to 100, so this select will return only three rows. What I need to do, to get also one (probably null or dummy) row for 666?
Thanks!
You could use union:
select * from table
where table_id in (1, 2, 3);
union
select 666 as table_id, other_fields_with_dummy_values_in_table from dual;
is how you could do it in Oracle. The from dual
might vary depending on what database system you're using.
Just be aware that if you use union, your dummy query MUST select the same records as the real query.