select regexp_replace('home care','home care','care') as column1,
regexp_replace('home care','home care','home') as column2
from WORDLIST w
输出:
column1 column2
care home
然后
select regexp_replace('care home','care home','home') as column3,
regexp_replace('care home','care home','care') as column4
from WORDLIST w
输出:
column3 column4
home care
因此,现在我想通过将一个选择语句嵌套到另一个没有“ join”字样且没有where子句的选择语句来将这两个正则表达式连接在一起,输出应如下所示:
column1 column2 column3 column4
care home home care
任何建议,我将不胜感激!
答案 0 :(得分:0)
下面的代码应该可以工作,它确实使用了强制连接和'join on 1 = 1'
select
w1.column1
,w1.column2
,w2.column3
,w2.column4
from(
select regexp_replace('home care','home care','care') as column1, regexp_replace('home care','home care','home') as column2 from WORDLIST w
) as w1
left join (
select regexp_replace('care home','care home','home') as column3, regexp_replace('care home','care home','care') as column4 from WORDLIST w
) as w2 on 1 = 1
答案 1 :(得分:0)
好吧,您可以尝试以下几种方法:
只需使用一个SELECT:
select regexp_replace('home care','home care','care') as column1,
regexp_replace('home care','home care','home') as column2,
regexp_replace('care home','care home','home') as column3,
regexp_replace('care home','care home','care') as column4
from WORDLIST w
使用交叉联接:
SELECT s1.COLUMN1,
s1.COLUMN2,
s2.COLUMN3,
s2.COLUMN4
FROM (select regexp_replace('home care','home care','care') as column1,
regexp_replace('home care','home care','home') as column2
from WORDLIST) s1
CROSS JOIN (select regexp_replace('care home','care home','home') as column3,
regexp_replace('care home','care home','care') as column4
from WORDLIST) s2
请注意,根据WORDLIST
中有多少行,这些查询返回的行可能会比您想要的多。 db<>fiddle here
您不妨考虑使用SELECT...FROM DUAL