惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
D
Docker
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
WordPress大学
WordPress大学
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
H
Help Net Security
Vercel News
Vercel News
S
SegmentFault 最新的问题
罗磊的独立博客
F
Full Disclosure
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
Last Week in AI
Last Week in AI
V
V2EX
腾讯CDC
IT之家
IT之家
爱范儿
爱范儿
博客园 - Franky
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Help Net Security
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
A
Arctic Wolf
Cyberwarzone
Cyberwarzone
Simon Willison's Weblog
Simon Willison's Weblog
AWS News Blog
AWS News Blog
S
Schneier on Security
GbyAI
GbyAI
Schneier on Security
Schneier on Security
O
OpenAI News
F
Fortinet All Blogs
Y
Y Combinator Blog
Forbes - Security
Forbes - Security
NISL@THU
NISL@THU
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
MongoDB | Blog
MongoDB | Blog

博客园 - 每天进步多一点

MySQL5.7实现row_number()和over()函数 C#学习相关系列之Linq用法---group和join相关用法 linq group by having 实现 常用知识-T-SQL优化 mysql窗口函数、Mysql分析函数 MySQL系列三(定位慢SQL、索引优化、SQL优化)Using filesort MySQL 内存相关参数设置 MySQL COALESCE 函数使用详解 SQL性能优化指南:如何优化MySQL多表join场景 MySQL内部临时表(Using temporary)案例详解及优化解决方法 cookie操作类(加密,获取,删除) MySql 5.7 索引不存在则创建,存在则忽略 SQL SERVER年月周日超止时间 数据抽取的常见理论方法 ETL系列-数据抽取(Extract) 常用时间sql语句 数据库运维:mysql 数据库迁移方法-mysqldump 了解MySQL中的JSON_ARRAYAGG和JSON_OBJECT函数 如何看懂explain工具信息,使用explain工具来分析索引 mysql 如何查看sql语句执行时间和效率
MySQL的IFNULL()、ISNULL()、NULLIF()函数用法说明
每天进步多一点 · 2025-11-28 · via 博客园 - 每天进步多一点

1、IFNULL() 函数

MySQL IFNULL 函数是 MySQL 控制流函数之一。

它有两个参数,第一个参数不为 NULL 时返回。 否则,IFNULL 函数返回第二个参数。

这两个参数可以是文字值或表达式。

IFNULL(expression1,expression2);

如果 expression1 不为 NULL,则 IFNULL 函数返回 expression1,否则返回 expression2

2、ISNULL() 函数

MySQL ISNULL() 函数用于检查表达式是否为 NULL

如果传递的表达式为 NULL,则此函数返回 1,否则返回 0。

ISNULL() 函数接受表达式作为参数,并根据传递的参数返回一个整数值 0 或 1。

3、NULLIF() 函数

MySQL NULLIF() 函数用于比较两个表达式

如果两个表达式相等,NULLIF() 函数返回 NULL,否则返回第一个表达式。

NULLIF() 函数接受表达式作为参数,如果它们相等则返回 NULL。

NULLIF(expression1, expression2)

如果传递的两个表达式相等,则 MySQL NULLIF() 函数返回 NULL,否则如果两个表达式不相等,则返回第一个表达式。

4、总结

IFNULL()、ISNULL()、NULLIF()函数都是用来对值或者表达式进行判断的,区别在于返回值,需要我们根据实际业务使用对应的函数。