此处测试示例:http ://sqlfiddle.com/#!4/037ffe/3
select
t1.col1 AS t1col1, t2.col1 AS t2col1
from
MyTable t1
left join MyTable2 t2
on t2.col1 like '%' || t1.col1 || '%'
包含 DDL 的完整示例:
CREATE TABLE MyTable (col1 varchar2(9));
INSERT ALL
INTO MyTable (col1)
VALUES ('AAA')
INTO MyTable (col1)
VALUES ('BBB')
INTO MyTable (col1)
VALUES ('CCC')
SELECT * FROM dual;
CREATE TABLE MyTable2 (col1 varchar2(18));
INSERT ALL
INTO MyTable2 (col1)
VALUES ('GHKGH AAAh')
INTO MyTable2 (col1)
VALUES ('dhsjsBvd')
INTO MyTable2 (col1)
VALUES ('bdnd CCC b')
SELECT * FROM dual;
select
t1.col1 AS t1col1, t2.col1 AS t2col1
from
MyTable t1
left join MyTable2 t2
on t2.col1 like '%' || t1.col1 || '%'
结果集:
T1COL1 T2COL1
AAA GHKGH AAAh
BBB(空)
CCC bdnd CCC b