Home > Database > Mysql Tutorial > Mysql&IFNULL,NULLIF,ISNULL_MySQL

Mysql&IFNULL,NULLIF,ISNULL_MySQL

WBOY
Release: 2016-06-01 13:01:53
Original
798 people have browsed it

最近用到mysql中的一些函数,有些也是第一次遇到,所以记录下来:

1. isnull(expr)

用法:expr为null,那么isnull( ) 的返回值为 1,否则返回值为 0。
2. IFNULL(expr1,expr2)

用法:如果expr1不为 NULL,则 IFNULL( ) 的返回值为 expr1; 否则其返回值为expr2。

3.NULLIF(expr1,expr2)

用法:如果expr1=expr2 成立,那么返回值为NULL,否则返回值为 expr1。

这和CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END相同。


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