Home > Database > Mysql Tutorial > 【MySQL函数】MYSQL IFNULL跟IF函数的使用

【MySQL函数】MYSQL IFNULL跟IF函数的使用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:15:30
Original
1327 people have browsed it

【MySQL函数】MYSQL IFNULL和IF函数的使用 下文对MYSQL IFNULL函数的使用进行了详细的叙述,供您参考学习,如果您在MYSQL IFNULL函数使用方面遇到过类的问题,不妨一看。 MYSQL IFNULL(expr1,expr2) 如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2。

【MySQL函数】MYSQL IFNULL和IF函数的使用

下文对MYSQL IFNULL函数的使用进行了详细的叙述,供您参考学习,如果您在MYSQL IFNULL函数使用方面遇到过类似的问题,不妨一看。

MYSQL IFNULL(expr1,expr2)          
如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2。IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境。          
mysql> select IFNULL(1,0);      
                     -> 1      
mysql> select IFNULL(0,10);      
                     -> 0      
mysql> select IFNULL(1/0,10);      
                     -> 10      
mysql> select IFNULL(1/0,'yes');      
                     -> 'yes '    
   

       


IF(expr1,expr2,expr3)          
如果expr1是TRUE(expr10且expr1NULL),那么IF()返回expr2,否则它返回expr3。IF()返回一个数字或字符串值,取决于它被使用的上下文。          
mysql> select IF(1>2,2,3);      
                     -> 3      
mysql> select IF(1                      -> yes     
mysql> select IF(strcmp('test','test1'),'yes','no');   //strcmp('test','test1')=-1   
                     -> yes     
     
     
     

Related labels:
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template