SQLite coalesce() 函数使用指南

来源:这里教程网 时间:2026-03-25 18:28:18 作者:

SQLite

coalesce()
函数返回参数列表中第一个不是 NULL 的值。

coalesce()
语法

这里是 SQLite

coalesce()
函数的语法:

coalesce(value1[, value2 ...])

参数

value1[, value2 ...]
必需的。 参数列表。您至少应该提供一个参数。

返回值

SQLite

coalesce()
函数返回参数列表中第一个不是
NULL
的值。如果全部参数都是
NULL
,该函数将返回
NULL

如果您没有为

coalesce()
提供参数,SQLite 将返回一个错误。

coalesce()
示例

SELECT     coalesce(NULL, 100),    coalesce(NULL, NULL);

 coalesce(NULL, 100) = 100coalesce(NULL, NULL) =

这里,

coalesce(NULL, 100)
的参数中
100
是第一个非 NULL 的值,因此返回了
100
coalesce(NULL, NULL)
的全部参数都是
NULL
,因此返回了
NULL

相关推荐

热文推荐