SQL “Join” on null values

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

    Just throwing this out there -- is there a way you could coalesce those nulls into a known value, like an empty string? Not knowing much about how your table is laid out means that I can't be sure if you'll be losing meaning that way -- i.e. having an empty string represent "user refused to enter a phone number" and NULL being "we forgot to ask about it", or something like that?

    Odds are it's not possible, I'm sure, but if it is, you'll have known values to compare and you can get a legit join that way.

提交回复
热议问题