Home > Database > Mysql Tutorial > mysql中将null值转换为0的语句

mysql中将null值转换为0的语句

WBOY
Release: 2016-06-07 18:03:23
Original
1744 people have browsed it

mysql中将null值转换为0的语句,在mysql数据库开发中,如果后期添加了字段那么这些值为空值null,我们在使用者需要将null转换为0方便后期的控制就需要下面的代码了。

代码如下:
SELECT
IF(AVG(cai.conversionsRate) IS NULL,0,AVG(cai.conversionsRate))
AS conversionsRate
FROM campaign_info cai
WHERE insertTime BETWEEN '2011-02-01' AND '2011-02-04' AND googleCampaignId=23331401

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template