SQL “Join” on null values

前端 未结 14 1325
旧巷少年郎
旧巷少年郎 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:50

    @Sarath Avanavu

    This one is not the best approach. If TA.COL1 keeps value 0 and TB.COL2 is NULL it will join those records, which is not correct.

    SELECT *
    FROM TABLEA TA
    JOIN TABLEB TB ON NVL(TA.COL1,0)=NVL(TB.COL2,0);
    

提交回复
热议问题