MySQL, coalesce equivalent for empty values?

后端 未结 4 2312
囚心锁ツ
囚心锁ツ 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:10

    This worked for me:

    SELECT IF(myValue > 0, myValue, 'empty string') AS Value FROM myTable;
    

提交回复
热议问题