PostgreSQL中类似MySQL中的IFNULL
函数用法
COALESCE
PostgreSQL
select COALESCE(0, 2) as new_field;
select COALESCE(NULL, 2) as new_field;
select COALESCE(case when NULL then NULL else '30'::int END) as new_field;
等价于MySQL中的IFNULL函数
IFNULL
MySQL
如果第一个参数不为NULL,则取第一个值;
如果第一个参数为NULL,那么函数取第二个参数的值。
select IFNULL(0, 2) as new_field;
select IFNULL(NULL, 2) as new_field;