当前位置:网站首页>MYSQL IFNULL使用功能
MYSQL IFNULL使用功能
2022-07-05 20:48:00 【全栈程序员站长】
大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。
稍后的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(expr1<>0且expr1<>NULL),那么IF()返回expr2。否则它返回expr3。IF()返回一个数字或字符串值,取决于它被使用的上下文。
mysql> select IF(1>2,2,3); -> 3 mysql> select IF(1<2,yes,no); -> yes mysql> select IF(strcmp(test,test1),yes,no); -> no expr1作为整数值被计算。它意味着假设你正在測试浮点或字符串值。你应该使用一个比較操作来做。
mysql> select IF(0.1,1,0); -> 0 mysql> select IF(0.1<>0,1,0); -> 1 在上面的第一种情况中。IF(0.1)返回0,由于0.1被变换到整数值, 导致測试IF(0)。这可能不是你期望的。在另外一种情况中,比較測试原来的浮点值看它是否是非零。比較的结果被用作一个整数。
CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result …] [ELSE result] END CASE WHEN [condition] THEN result [WHEN [condition] THEN result …] [ELSE result] END 第一个版本号返回result。当中value=compare-value。第二个版本号中假设第一个条件为真,返回result。假设没有匹配的result值,那么结果在ELSE后的result被返回。
假设没有ELSE部分。那么NULL被返回。 mysql> SELECT CASE 1 WHEN 1 THEN “one” WHEN 2 THEN “two” ELSE “more” END; -> “one” mysql> SELECT CASE WHEN 1>0 THEN “true” ELSE “false” END; -> “true” mysql> SELECT CASE BINARY “B” when “a” then 1 when “b” then 2 END; -> NULL
下文对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(expr1<>0且expr1<>NULL),那么IF()返回expr2,否则它返回expr3。IF()返回一个数字或字符串值,取决于它被使用的上下文。 mysql> select IF(1>2,2,3); -> 3 mysql> select IF(1<2,yes,no); -> yes mysql> select IF(strcmp(test,test1),yes,no); -> no expr1作为整数值被计算,它意味着假设你正在測试浮点或字符串值,你应该使用一个比較操作来做。
mysql> select IF(0.1,1,0); -> 0 mysql> select IF(0.1<>0,1,0); -> 1 在上面的第一种情况中。IF(0.1)返回0。由于0.1被变换到整数值, 导致測试IF(0)。这可能不是你期望的。在另外一种情况中,比較測试原来的浮点值看它是否是非零,比較的结果被用作一个整数。
CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result …] [ELSE result] END CASE WHEN [condition] THEN result [WHEN [condition] THEN result …] [ELSE result] END 第一个版本号返回result。当中value=compare-value。第二个版本号中假设第一个条件为真。返回result。假设没有匹配的result值,那么结果在ELSE后的result被返回。假设没有ELSE部分,那么NULL被返回。 mysql> SELECT CASE 1 WHEN 1 THEN “one” WHEN 2 THEN “two” ELSE “more” END; -> “one” mysql> SELECT CASE WHEN 1>0 THEN “true” ELSE “false” END; -> “true” mysql> SELECT CASE BINARY “B” when “a” then 1 when “b” then 2 END; -> NULL
版权声明:本文博客原创文章。博客,未经同意,不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117657.html原文链接:https://javaforall.cn
边栏推荐
- phpstudy小皮的mysql点击启动后迅速闪退,已解决
- 挖财商学院给的证券账户安全吗?可以开户吗?
- ProSci LAG-3 重组蛋白说明书
- Abnova CD81 monoclonal antibody related parameters and Applications
- Applet event binding
- Is it safe to open an account online? Where can I get a low commission?
- Abnova maxpab mouse derived polyclonal antibody solution
- Norgen AAV extractant box instructions (including features)
- Is the securities account given by the school of Finance and business safe? Can I open an account?
- Duchefa丨S0188盐酸大观霉素五水合物中英文说明书
猜你喜欢

重上吹麻滩——段芝堂创始人翟立冬游记

Abnova blood total nucleic acid purification kit pre installed relevant instructions

Specification of protein quantitative kit for abbkine BCA method

Abbkine trakine F-actin Staining Kit (green fluorescence) scheme

研學旅遊實踐教育的開展助力文旅產業發展
mysql全面解析json/数组

Duchefa MS medium contains vitamin instructions

Abnova e (diii) (WNV) recombinant protein Chinese and English instructions
![Ros2 topic [01]: installing ros2 on win10](/img/46/550945aa36d2bec03e5dd29404f409.png)
Ros2 topic [01]: installing ros2 on win10

研学旅游实践教育的开展助力文旅产业发展
随机推荐
【UE4】UnrealInsight获取真机性能测试报告
Duchefa丨P1001植物琼脂中英文说明书
基于AVFoundation实现视频录制的两种方式
Classic implementation of the basic method of intelligent home of Internet of things
Clear app data and get Icon
Open source SPL eliminates tens of thousands of database intermediate tables
AI 从代码中自动生成注释文档
[record of question brushing] 1 Sum of two numbers
Kubernetes resource object introduction and common commands (V) - (configmap & Secret)
Frequent MySQL operations cause table locking problems
清除app data以及获取图标
leetcode:1755. 最接近目标值的子序列和
培养机器人教育创造力的前沿科技
小程序全局配置
Leetcode (347) - top k high frequency elements
挖财商学院给的证券账户安全吗?可以开户吗?
Ros2 topic [01]: installing ros2 on win10
PHP反序列化+MD5碰撞
常用的视图容器类组件
Fundamentals - configuration file analysis