【问题标题】:sql check the select return nullsql检查选择返回null
【发布时间】:2013-02-19 18:14:52
【问题描述】:

我要查询可以检查完全null 例如:

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)

【问题讨论】:

    标签: mysql sql case-when sql-like


    【解决方案1】:

    听起来你需要 COALESCE() 函数:

    SELECT COALESCE(a, b, c, ..., 'default')
    

    这将返回参数列表中的第一个非空值,例如

    COALESCE(null, null, 'hello')
    

    返回hello

    【讨论】:

      猜你喜欢
      • 2018-09-03
      • 2021-07-05
      • 2011-11-30
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 2020-06-24
      • 1970-01-01
      相关资源
      最近更新 更多