当前位置:网站首页>Condition judgment function of MySQL function summary
Condition judgment function of MySQL function summary
2022-07-26 08:13:00 【Operation and maintenance home】
Condition judgment function is also called control flow function , According to different conditions , Process of executing response .
mysqlThe functions for conditional judgment inif、ifunllandcaseetc. .
IF(expr,v1,v2) function
IF(expr,v1,v2): If the expression expr yes TRUE(expr <> 0 and expr <> null), The return value is V1; Otherwise, the return value is V2.
mysql> select if (1>2, 2, 3), if (1<2, 'yes', 'no');
+----------------+-----------------------+
| if (1>2, 2, 3) | if (1<2, 'yes', 'no') |
+----------------+-----------------------+
| 3 | yes |
+----------------+-----------------------+
1 row in set (0.00 sec)
mysql>
tip :
If V1 perhaps V2 Only one of them is clear
null, beif()The result type of the function is nonnullThe result type of the expression .
IFNULL(v1,v2) function
ifnull(v1,v2): If V1 Not for null, be ifnull() The return value of is v1; Otherwise, the return value is v2.
ifnull() The return value of is a number or string , The specific situation depends on the context .
mysql> select ifnull(1, 2), ifnull(null, 'yunweijia'), ifnull(1/0, 'heihei');
+--------------+---------------------------+-----------------------+
| ifnull(1, 2) | ifnull(null, 'yunweijia') | ifnull(1/0, 'heihei') |
+--------------+---------------------------+-----------------------+
| 1 | yunweijia | heihei |
+--------------+---------------------------+-----------------------+
1 row in set (0.00 sec)
mysql>
CASE function
case expr when v1 then r1 [when v2 then 2]...[else rn+1]end: If expr The value is equal to some vn, Then return to the corresponding position then The latter result ; If it is not equal to all values , Then return to else hinder rn+1.
mysql> select case 2 when 1 then 'one' when '2' then 'two' else 'more' end;
+--------------------------------------------------------------+
| case 2 when 1 then 'one' when '2' then 'two' else 'more' end |
+--------------------------------------------------------------+
| two |
+--------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql> select case 5 when 1 then 'one' when '2' then 'two' else 'more' end;
+--------------------------------------------------------------+
| case 5 when 1 then 'one' when '2' then 'two' else 'more' end |
+--------------------------------------------------------------+
| more |
+--------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
tip :
May, in accordance with the
shellMediumifSentence to understand .One
caseThe default return value type of an expression is the compatible collection type of any return value , But it depends on the context .
thus , In this paper, the end .
For more information, go to VX official account “ Operation and maintenance home ” , Get the latest article .
------ “ Operation and maintenance home ” ------
------ “ Operation and maintenance home ” ------
------ “ Operation and maintenance home ” ------
linux Interrupt exception ,linuxuml modeling ,linux Compile multiple source files ,linux How to update the time ,linux Paging video tutorial in ,
linux How to decompress gzip,linux Unzip a directory , How to close linux gateway ,linux Document structure diagram ,linux Improve the permission to execute ,
linux What mark is used in the document , Network security linux strengthening ,linux Check email in ,linux Change the background color ,linux Build a website under the environment .
边栏推荐
- 2022/7/11 exam summary
- 有点牛逼,一个月13万+
- 【 fastjson1.2.24反序列化漏洞原理代码分析】
- Burp suite Chapter 3 how to use burp suite agent
- 为啥谷歌的内部工具不适合你?
- Zroi easy sum (generating function, block, DP, combination, polynomial)
- Using producer consumer model and dpkt to process pcap files
- Burp Suite-第二章 Burp Suite代理和浏览器设置
- 一键部署LAMP和LNMP架构
- Summary of common methods of string
猜你喜欢

Burp suite Chapter 6 how to use burp spider

Traversal mode of list, set, map, queue, deque, stack

Basic introduction of JDBC

C # get the information of the selected file

Pycharm code specification tool flake8

小组成员参加2022中国多媒体大会

CentOS install mysql5.7

美女裸聊一时爽,裸聊结束火葬场!

Burp Suite-第三章 如何使用Burp Suite代理

全网最全:Mysql六种约束详解
随机推荐
Zroi easy sum (generating function, block, DP, combination, polynomial)
Summary of distributed related interview questions
JSP built-in object (implicit object) -- input / output object
小蜜蜂吉他谱 高八度和低八度
Exam summary on July 15, 2022
How WPS sets page headers page by page
Software engineering -- dental clinic -- demand acquisition
An empirical study on urban unemployment in Guangxi (Macroeconomics)
Summary of common methods of string
Introduction to arrays -- array
外卖小哥,才是这个社会最大的托底
宇宙第一 IDE 霸主,换人了。。。
Burp Suite-第一章 Burp Suite 安装和环境配置
2022/7/12 exam summary
Burp Suite-第四章 SSL和Proxy高级选项
分享高压超低噪声LDO测试结果(High Voltage Ultra-low Noise LDO)
The difference between LinkedList and ArrayList
Pycharm code specification tool flake8
万字长文 | 深入理解 OpenFeign 的架构原理
Exam summary on July 13, 2022