当前位置:网站首页>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
边栏推荐
- 插值查找的简单理解
- [quick start of Digital IC Verification] 2. Through an example of SOC project, understand the architecture of SOC and explore the design process of digital system
- The development of research tourism practical education helps the development of cultural tourism industry
- 3.3、项目评估
- [Yugong series] go teaching course in July 2022 004 go code Notes
- 2.8 basic knowledge of project management process
- Abnova丨 MaxPab 小鼠源多克隆抗体解决方案
- Popular science | does poor English affect the NPDP exam?
- 获取前一天的js(时间戳转换)
- Analyze the knowledge transfer and sharing spirit of maker Education
猜你喜欢
珍爱网微服务底层框架演进从开源组件封装到自研
Abnova丨血液总核酸纯化试剂盒预装相关说明书
表单文本框的使用(二) 输入过滤(合成事件)
教你自己训练的pytorch模型转caffe(一)
ProSci LAG3抗体的化学性质和应用说明
教你自己训练的pytorch模型转caffe(二)
Abnova CRISPR spcas9 polyclonal antibody protocol
Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
研學旅遊實踐教育的開展助力文旅產業發展
Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Nanjing
随机推荐
序列联配Sequence Alignment
2022 Beijing eye health products exhibition, eye care products exhibition, China eye Expo held in November
Classic implementation method of Hongmeng system controlling LED
ProSci LAG3抗体的化学性质和应用说明
中国的软件公司为什么做不出产品?00后抛弃互联网;B站开源的高性能API网关组件|码农周刊VIP会员专属邮件周报 Vol.097
证券开户选择哪个证券比较好?网上开户安全么?
Implementation of redis unique ID generator
ts 之 属性的修饰符public、private、protect
Use of thread pool
Abnova CD81 monoclonal antibody related parameters and Applications
Chemical properties and application instructions of prosci Lag3 antibody
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
Abbkine丨TraKine F-actin染色试剂盒(绿色荧光)方案
Dry goods navigation in this quarter | Q2 2022
1. Strengthen learning basic knowledge points
How to form standard interface documents
Abnova 环孢素A单克隆抗体,及其研究工具
leetcode:1755. 最接近目标值的子序列和
mysql全面解析json/数组
小程序事件绑定