当前位置:网站首页>MySQL ifnull usage function
MySQL ifnull usage function
2022-07-05 20:51:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack , I've prepared for you today Idea Registration code .
Later MYSQL IFNULL Specific narratives that use this function , For your reference , Suppose you MYSQL IFNULL There is something wrong with the functional category of the clause . The most beautiful .
MYSQL IFNULL(expr1,expr2) hypothesis expr1 No NULL,IFNULL() return expr1. Otherwise it returns expr2.IFNULL() Returns a numeric or string value , Depending on the context in which it is used . 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) hypothesis expr1 yes TRUE(expr1<>0 And expr1<>NULL), that IF() return expr2. Otherwise it returns expr3.IF() Returns a numeric or string value , Depending on the context in which it is used .
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 Is calculated as an integer value . It means assuming that you are testing floating-point or string values . You should use a comparison operation to do .
mysql> select IF(0.1,1,0); -> 0 mysql> select IF(0.1<>0,1,0); -> 1 In the first case above .IF(0.1) return 0, because 0.1 Is transformed to an integer value , Cause test IF(0). This may not be what you expect . In another case , Compare and test the original floating-point value to see if it is non-zero . The result of the comparison is used as an integer .
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 The first version number returns result. among value=compare-value. The second version number assumes that the first condition is true , return result. Suppose there is no match result value , So the result is ELSE After result Returned .
Suppose there is no ELSE part . that NULL Returned . 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
The following is true of MYSQL IFNULL The use of function is described in detail , For your reference . Suppose you are in MYSQL IFNULL We have encountered similar problems in the use of functions , It's better to have a look .
MYSQL IFNULL(expr1,expr2) hypothesis expr1 No NULL,IFNULL() return expr1, Otherwise it returns expr2.
IFNULL() Returns a numeric or string value , Depending on the context in which it is used .
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) hypothesis expr1 yes TRUE(expr1<>0 And expr1<>NULL), that IF() return expr2, Otherwise it returns expr3.IF() Returns a numeric or string value , Depending on the context in which it is used . 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 Is calculated as an integer value , It means assuming that you are testing floating-point or string values , You should use a comparison operation to do .
mysql> select IF(0.1,1,0); -> 0 mysql> select IF(0.1<>0,1,0); -> 1 In the first case above .IF(0.1) return 0. because 0.1 Is transformed to an integer value , Cause test IF(0). This may not be what you expect . In another case , Compare and test the original floating-point value to see if it is non-zero , The result of the comparison is used as an integer .
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 The first version number returns result. among value=compare-value. The second version number assumes that the first condition is true . return result. Suppose there is no match result value , So the result is ELSE After result Returned . Suppose there is no ELSE part , that NULL Returned . 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
Copyright notice : This article is an original blog article . Blog , Without consent , Shall not be reproduced .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117657.html Link to the original text :https://javaforall.cn
边栏推荐
- [UE4] unrealinsight obtains the real machine performance test report
- ts 之 属性的修饰符public、private、protect
- Implementation of redis unique ID generator
- Propping of resources
- Nprogress plug-in progress bar
- Is it safe to open an account online? Where can I get a low commission?
- Abnova blood total nucleic acid purification kit pre installed relevant instructions
- Duchefa d5124 md5a medium Chinese and English instructions
- Selenium element information
- [Yugong series] go teaching course in July 2022 004 go code Notes
猜你喜欢
Norgen AAV提取剂盒说明书(含特色)
Abnova e (diii) (WNV) recombinant protein Chinese and English instructions
Abnova丨CRISPR SpCas9 多克隆抗体方案
Abnova丨荧光染料 620-M 链霉亲和素方案
基于flask写一个接口
研学旅游实践教育的开展助力文旅产业发展
Abbkine丨TraKine F-actin染色试剂盒(绿色荧光)方案
教你自己训练的pytorch模型转caffe(三)
Écrire une interface basée sur flask
IC popular science article: those things about Eco
随机推荐
Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
请查收.NET MAUI 的最新学习资源
Applet project structure
[Yugong series] go teaching course in July 2022 004 go code Notes
台风来袭!建筑工地该如何防范台风!
Kubernetes resource object introduction and common commands (V) - (configmap & Secret)
matplotlib绘图润色(如何形成高质量的图,例如设如何置字体等)
Applet global configuration
清除app data以及获取图标
10000+ 代码库、3000+ 研发人员大型保险集团的研发效能提升实践
IC popular science article: those things about Eco
当用户登录,经常会有实时的下拉框,例如,输入邮箱,将会@qq.com,@163.com,@sohu.com
MySQL InnoDB架构原理
Duchefa细胞分裂素丨二氢玉米素 (DHZ)说明书
Analyze the knowledge transfer and sharing spirit of maker Education
Material Design组件 - 使用BottomSheet展现扩展内容(二)
bazel是否有学习的必要
Norgen AAV提取剂盒说明书(含特色)
Duchefa s0188 Chinese and English instructions of spectinomycin hydrochloride pentahydrate
从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题