'SQL Query based on value of another table
Suppose That I have Table A and Table B as follow. How would I get my expected outcome ? The filtering should be dynamically based on values in Table A as follow
SELECT * FROM TableB
WHERE
(Start = 'A' AND End = 'B')
OR (Start = 'C' AND End = 'D')
OR (Start = 'B' AND End = 'A')
Table A
Start End
A B
C D
B A
Table B
ID Start End Date
1 A B 2021-01-01
2 A B 2021-01-01
3 C D 2021-01-01
4 B A 2021-01-01
5 C D 2021-01-01
6 E A 2021-01-01
6 D C 2021-01-01
Expected Result
ID Start End Date
1 A B 2021-01-01
2 A B 2021-01-01
3 C D 2021-01-01
4 B A 2021-01-01
5 C D 2021-01-01
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
