匹配两列 [英] Matching two columns
问题描述
我有两个桌子.表A有两列,表B有一列.
I have a two tables. TableA has two columns and TableB has one column.
ID | TERM_A
ID | TERM_A
TERM_B
TERM_A和TERM_B列包含term. 我想在Oracle 10上使用sql从TableA的TERM_A列和TableB的TERM_B列中获取相交术语. 我的结果表应该是这样的:
TERM_A and TERM_B column contain terms . I want to take intersect terms from TERM_A column of TableA and TERM_B column of TableB with sql on Oracle 10. My result table should be like that :
-
结果表
ID | INTERSECT_TERMS
Result_Table
ID | INTERSECT_TERMS
我该怎么做?
推荐答案
INTERSECT运算符返回一个结果集,其中包含两个查询中的匹配值.
The INTERSECT operator returns a resultset containing the matching values from the two queries.
select * from tableA
where term_a in
( select term_a from tableA
intersect
select term_b from tableB )
;
由于要从TABLEA中选择其他列,因此需要将相交的输出用作子查询.
Because you want to select additional columns from TABLEA you need to use the output of the intersection as a sub-query.
这篇关于匹配两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!