The constructs with in
won't work, unless you have a query that returns all values you specify and maybe a bit more, so if you have a set of letters, you could input it in a query that returns all letters. That would give you something like this:
select
*
from (
select chr(96 + level) as letter
from dual
connect by level <= 26)
where
letter in ('a', 'a', 'b');
Of course, that would work for fixed limited sets, like the whole alphabet, or even numbers from 1 to 1000, but it's not a way to convert any set to a distinct list.
Alternative: dual joins
You can select a single value using the fake table dual
. You can even make a union of such selects, although it looks a bit cumbersome:
select 'a' as MyValue from dual
union select 'a' from dual
union select 'b' from dual
If you use union
instead of union all
, the query will implicitly return distinct values only.
Alternative: Split string
If you have the values in a string, you could split that string and return the items. There are various ways to do that, but not out of the box. You could have a look at the question Splitting string into multiple rows to which the answers show various solutions.