MySQL, coalesce equivalent for empty values?

后端 未结 4 2279
囚心锁ツ
囚心锁ツ 2020-12-25 09:51

I know that coalesce will return the first non-null value that is passed to it. is there something simlilar that will return the first not empty / not false value?

e

4条回答
  •  春和景丽
    2020-12-25 10:01

    You could make NULL from empty string in MySQL :

    SELECT coalesce(NULLIF(email, ''), 'user@domain.com') FROM users WHERE id=1000000;
    

提交回复
热议问题