SQL Server JOIN missing NULL values

前端 未结 8 1509
感情败类
感情败类 2020-12-04 15:15

Suppose I had the following 2 tables:

      Table1:                                Table2:
Col1:      Col2:     Col3:             Col1:       Col2:       Col         


        
8条回答
  •  悲哀的现实
    2020-12-04 15:51

    Try using additional condition in join:

    SELECT Table1.Col1, Table1.Col2, Table1.Col3, Table2.Col4
    FROM Table1 
    INNER JOIN Table2
    ON (Table1.Col1 = Table2.Col1 
        OR (Table1.Col1 IS NULL AND Table2.Col1 IS NULL)
       )
    

提交回复
热议问题