gpt4 book ai didi

mysql - sql检查select返回null

转载 作者:行者123 更新时间:2023-11-29 08:37:03 25 4
gpt4 key购买 nike

我想要一个查询可以检查完全为空例如:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com