读书人

运用 IFNULL 或 COALESCE

发布时间: 2013-03-14 10:33:15 作者: rapoo

使用 IFNULL 或 COALESCE
SELECT IFNULL(SUM(Column1), 0) AS total FROM...SELECT COALESCE(SUM(Column1), 0) AS total FROM...

?The difference between them is that IFNULL is a MySQL extension that takes two arguments, and COALESCE is a standard SQL function that can take one or more arguments. When you only have two arguments using IFNULL is slightly faster, though here the difference is insignificant since it is only called once.

读书人网 >其他数据库

热点推荐