在连接中使用的 Oracle SQL 类语句
Oracle SQL like statement to use in a join
我正在尝试使用 JOIN 在 Oracle 中编写查询以提取必要的记录。
表 1
Value OtherValue1
123AB Text
表 2
ValueDescription OtherValue2
AH/123AB/C/2020 Some text value
我的目标是能够加入 table1.Value = table2.ValueDescription 上的 2 个表,例如:
Select a.*, b.*
from table1 a, table2 b
where a.Value = b.Value
这样的事情可能吗?
您可以使用:
Select a.*, b.*
from table1 a join
table2 b
on b.Value like '%' || a.value || '%';
这可能性能不佳。
根据您真正想做的事情,您可能需要包含分隔符:
Select a.*, b.*
from table1 a join
table2 b
on b.Value like '%/' || a.value || '/%';
我正在尝试使用 JOIN 在 Oracle 中编写查询以提取必要的记录。
表 1
Value OtherValue1
123AB Text
表 2
ValueDescription OtherValue2
AH/123AB/C/2020 Some text value
我的目标是能够加入 table1.Value = table2.ValueDescription 上的 2 个表,例如:
Select a.*, b.*
from table1 a, table2 b
where a.Value = b.Value
这样的事情可能吗?
您可以使用:
Select a.*, b.*
from table1 a join
table2 b
on b.Value like '%' || a.value || '%';
这可能性能不佳。
根据您真正想做的事情,您可能需要包含分隔符:
Select a.*, b.*
from table1 a join
table2 b
on b.Value like '%/' || a.value || '/%';