MySQL - JOIN a OR b

后端 未结 3 1458
猫巷女王i
猫巷女王i 2021-01-17 02:43

Let\'s say I have a TABLE a in which a COLUMN data is the one to join on for 2 other tables (TABLE b and TABLE

3条回答
  •  佛祖请我去吃肉
    2021-01-17 03:42

    You can left join to both of the b and c tables, then use whichever info field is not NULL:

    select coalesce(b.info, c.info) info
    from a
      left join b on a.data = b.data
      left join c on a.data = c.data
    

提交回复
热议问题