当前位置:网站首页>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
边栏推荐
- PHP反序列化+MD5碰撞
- 挖财商学院给的证券账户安全吗?可以开户吗?
- mysql全面解析json/数组
- Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
- Duchefa s0188 Chinese and English instructions of spectinomycin hydrochloride pentahydrate
- 教你自己训练的pytorch模型转caffe(二)
- Hongmeng OS' fourth learning
- go 文件路径操作
- 科普|英语不好对NPDP考试有影响吗 ?
- 序列联配Sequence Alignment
猜你喜欢
Duchefa cytokinin dihydrozeatin (DHZ) instructions
研學旅遊實踐教育的開展助力文旅產業發展
ProSci LAG3抗体的化学性质和应用说明
Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
Abnova e (diii) (WNV) recombinant protein Chinese and English instructions
学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
Abnova丨CRISPR SpCas9 多克隆抗体方案
解析创客教育的知识迁移和分享精神
The development of research tourism practical education helps the development of cultural tourism industry
Duchefa丨S0188盐酸大观霉素五水合物中英文说明书
随机推荐
Abnova丨 MaxPab 小鼠源多克隆抗体解决方案
中国管理科学研究院凝聚行业专家,傅强荣获智库专家“十佳青年”称号
CareerCup它1.8 串移包括问题
解读协作型机器人的日常应用功能
[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
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
Where is a good stock account? Is online account manager safe to open an account
The Chinese Academy of Management Sciences gathered industry experts, and Fu Qiang won the title of "top ten youth" of think tank experts
Point cloud file Dat file read save
ViewRootImpl和WindowManagerService笔记
表单文本框的使用(二) 输入过滤(合成事件)
Material design component - use bottomsheet to show extended content (II)
请查收.NET MAUI 的最新学习资源
leetcode:1755. 最接近目标值的子序列和
实现浏览页面时校验用户是否已经完成登录的功能
E. Singhal and numbers (prime factor decomposition)
hdu2377Bus Pass(构建更复杂的图+spfa)
Material Design组件 - 使用BottomSheet展现扩展内容(二)
Abnova CD81 monoclonal antibody related parameters and Applications
[record of question brushing] 1 Sum of two numbers