我知道 coalesce 将返回传递给它的第一个非空值。有没有类似的东西会返回第一个非空/非假值?
示例:
select FunctionIWant(0,'','banana') as fruit; //returns banana.
最佳答案
您可以在 MySQL 中将空字符串设为 NULL:
SELECT coalesce(NULLIF(email, ''), 'user@domain.example') FROM users WHERE id=1000000;
关于sql - MySQL,合并空值的等效项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4101564/