In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you two grammars about case when in MySQL, which will be analyzed and described from a professional point of view. I hope you can get something after reading this article.
Usage of Case when: once a WHEN is satisfied, this piece of data exits the CASE WHEN, regardless of other CASE.
There are two syntax for MySQL's case when:
Simple function
CASE [col_name] WHEN [value1] THEN [result1]... ELSE [default] END
Search function
CASE WHEN [expr] THEN [result1]... ELSE [default] END
Example:
1. Search function
CASE WHEN [expr] THEN [result1]... ELSE [default] END: the search function can write judgment, and the search function will only return the first qualified value, and other case will be ignored.
In # when expressions, you can use and to connect conditions SELECT NAME 'hero', age 'age', CASE WHEN age
< 18 THEN '少年' WHEN age < 30 THEN '青年' WHEN age >= 30 AND age < 50 THEN 'middle age' ELSE 'old age' END 'state' FROM user_info
2. Simple function
CASE [col_name] WHEN [value1] THEN [result1]... ELSE [default] END: enumerates all possible values for this field.
SELECT NAME 'hero', CASE NAME WHEN 'Dreven' THEN 'axe' WHEN 'Demacia-Galen' THEN 'sword' WHEN 'night hunter-VN' THEN' crossbow 'ELSE' no 'END' equipment 'FROM user_info SELECT NAME 'hero', CASE NAME WHEN 'Dreven' THEN 'axe' WHEN 'Demacia-Galen' THEN 'sword' WHEN 'night hunter-VN' THEN' crossbow 'ELSE' no 'END' equipment 'FROM user_info These are the two syntax of case when in MySQL shared by Xiaobian. If you have similar doubts, you might as well try it with reference to the above method. If you want to know more about it, please follow the industry information.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.