我想要一个查询可以检查完全为空 例如:
select a where
case
when a like %b%
then a like %b% (if after search every row of table still return null)
else
a like %c% (if have match in any row skip else statement)
最佳答案
听起来您需要 COALESCE() 函数:
SELECT COALESCE(a, b, c, ..., 'default')
这将返回参数列表中的第一个非空值,例如
COALESCE(null, null, 'hello')
返回hello
。
关于mysql - sql检查select返回null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14964519/