Table A
col 1 | col 2 |
---|---|
a | b |
c | d |
Table B
col 1 | col 2 |
---|---|
a | e |
b | f |
c | g |
d | h |
Result : Table C
col 1 | col 2 |
---|---|
e | f |
g | h |
CodePudding user response:
You can join table B twice such as
SELECT B1.col2 AS col1, B2.col2
FROM A
JOIN B B1
ON B1.col1 = A.col1
JOIN B B2
ON B2.col1 = A.col2