I'm trying to use a "literal" multi-column table for a join query with Oracle 11g.
Here's the best I've come up with, based on this answer ( this answer suggests a much nicer syntax, but it only works for a single-column table as far as I can tell):
SELECT * from
(
-- The ugly... it burns...
select 'APPLE' as n, 'FRUIT' as m from dual
union all select 'CARROT' as n, 'VEGGIE' as m from dual
union all select 'PEACH' as n, 'FRUIT' as m from dual
union all select 'CUCUMBER' as n, 'VEGGIE' as m from dual
union all select 'ORANGE' as n, 'FRUIT' as m from dual
)
Is there a less ugly way to create a multi-row, multi-column literal table in Oracle? Unfortunately, I cannot create temporary tables.
<rant>
As I've come to expect, PostgreSQL has a nice, sane syntax for literal tables, but Oracle is a mess.</rant>
EDIT: I had tried the row-value constructor syntax as suggested by @Mark Chesney but that doesn't work either: select n,m from dual where (n,m) in (...)
gives me an Invalid Identifier error.
select * from table()
queries – SpayROWNUM
of each subquery – Spay