SQL “Join” on null values

前端 未结 14 1319
旧巷少年郎
旧巷少年郎 2020-12-13 14:04

For reasons beyond my control, I need to join two tables and I need null values to match. The best option I could think of was to spit out a UUID and use that as my comparis

14条回答
  •  抹茶落季
    2020-12-13 14:47

    Maybe this would work, but I've never actually tried it:

    SELECT * 
    FROM T1 JOIN T2 
    ON T1.SOMECOL = T2.SOMECOL OR (T1.SOMECOL IS NULL AND T2.SOMECOL IS NULL)
    

提交回复
热议问题