SQL:将一列的字符串与另一个表列的子字符串匹配

时间:2016-10-08 02:22:22

标签: sql jointable

我有两个表t1和t3。如果t2字符串中存在t1字符串,我需要t3具有t1字符串。

t1-[mango, apple, Top]
t2-[{Ate mango}, {it was nice apple},{you are hero}, {apple shares top}] 

如果t1的字符串与t2的子字符串匹配,那么t3将 输出为t3

t3-[mango, apple, , {apple,top}]

enter image description here

1 个答案:

答案 0 :(得分:0)

Select
SecondCol Result
From
(
Select
Col2 FirstCol, 
UPPER(LISTAGG(Col1, ', ') WITHIN GROUP (ORDER BY Col2)) SecondCol
From
(Select Table1.T1 Col1, Table2.T1 Col2 From Table1,Table2
Where
Length(REGEXP_SUBSTR(UPPER(Table2.T1), UPPER(Table1.T1)))<>0
)
Group By Col2
);

Screenshot after executing above Query