在oracle中,可以将静态列表连接到表中吗?我的列表是这样的
ID
1
2
3
4
5
6
我不想为此列表创建表
但是,我想将该列表连接到一个包含ID的现有表中……希望对列表进行左连接
这个是可能的吗?
发布于 2018-12-05 08:32:52
您正在查找包含UNION
of SELECT FROM DUAL
的WITH
子句。
像这样:
WITH my_list AS (
select 'A' my_value from dual
UNION ALL select 'B' my_value from dual
UNION ALL select 'C' my_value from dual
)
SELECT
*
FROM
my_list
LEFT JOIN my_table ON my_table.my_field = my_list.my_value
;
发布于 2018-12-05 10:15:09
您可以在CTE中生成ID列表,然后将其连接到您想要的任何位置。
with id_list as (
select rownum as id
from dual
connect by level <= 6
)
select * from id_list;
ID
1
2
3
4
5
6
https://livesql.oracle.com/apex/livesql/s/hm2mczgx5udiig9vhryo86mfm
https://stackoverflow.com/questions/53623263
复制相似问题