我处于需要Full Outer加入两个表的情况,基于三个条件,但我不知道如何,
SELECT DISTINCT
TableA.*
FROM TableB
INNER JOIN TableC ON TableC.IDB = TableB.IDB
INNER JOIN TableD ON TableD.ID = dbo.TableC.IDA
FULL OUTER JOIN TableA
现在我想从TableA得到的是使用这些条件,
ColumnA = TableD.Column1
ColumnB = 'someGivenParameter'
Condition = All of 3 columns ColumnA, ColumnB or ColumnC of TableA are Null
表格
ColumnABC Key Value ColumnA ColumnB ColumnC ColumnD
1 TestFlag1 TRUE 1 14 NULL NULL
2 TestFlag2 FALSE 2 1 NULL NULL
3 TestFlag4 FALSE NULL NULL uid-1828 NULL
4 TestFlag3 FALSE NULL NULL NULL NULL
所需输出
ColumnABC Key Value ColumnA ColumnB ColumnC ColumnD
1 TestFlag1 TRUE 1 14 NULL NULL
3 TestFlag4 FALSE NULL NULL uid-1828 NULL
4 TestFlag3 FALSE NULL NULL NULL NULL
当ColumnA = 1且C列= uid-1828时
我真正想要的只是简单的话,
Inner Join TableA where ColumnA = TableB.ColumnA or ColumnA = NULL