In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the usage of MySQL string concatenation function". The explanation in this article is simple and clear, and it is easy to learn and understand. Please follow Xiaobian's train of thought to study and learn what the usage of MySQL string concatenation function is.
What is the usage of MySQL string addition function
For example: updatecdb_ex_sitesetviewlog=concat (viewlog,' http://www.cnblogs.com/qiantuwuliang/')
The above statement is to assign a value to the field viewlog after the MySQL string http://www.cnblogs.com/qiantuwuliang/ after the field viewlog field value
Column participation addition can not directly use the plus sign (+), you need to reference the function concat
Example: concat ('string', concat (column name, 'string'))
The above example contains two additions.
Ordinary strings can be added directly to 'string' + 'string'.
The date type of MySQL can be treated as a MySQL string.
What is the use of MySQL string concatenation function?
How to use it:
CONCAT (str1,str2, …)
Returns a string that results in a connection parameter. If any parameter is NULL, the return value is NULL.
Note:
If all parameters are non-binary strings, the result is a non-binary string.
If the argument contains any binary string, the result is a binary string.
A numeric parameter is converted to its equivalent binary string format; to avoid this, use the explicit type cast, such as:
SELECTCONCAT (CAST (int_colASCHAR), char_col)
The concat function of MySQL can concatenate one or more strings, such as
Mysql > selectconcat ('10'); +-+ | concat (' 10') | +-+ | 10 | +-+ 1rowinset (0.00sec) mysql > selectconcat +-+ | concat ('11, 22, 22, 33) | +-+ | 112233 | +-+ 1rowinset (0.00sec)
When concatenating a string, the concat function of MySQL returns NULL as long as one of them is NULL
Mysql > selectconcat; +-+ | concat ('11-+) | NULL | +-+ 1rowinset (0.00sec)
Concat_ws function in MySQL
How to use it:
CONCAT_WS (separator,str1,str2,...)
CONCAT_WS () stands for CONCATWithSeparator and is a special form of CONCAT (). The first parameter is the delimiter of the other parameters. The position of the delimiter is placed between the two strings to concatenate. The delimiter can be a string or other parameters.
Note:
If the delimiter is NULL, the result is NULL. Function ignores null values after any delimiter arguments.
If separated by commas after connection
Mysql > selectconcat_ws (',','11, 22, 22, 33) +-- + | concat_ws (',','11) 1rowinset (0.00sec) | +-- + | 11 people 22 minutes 33 | +-- + 10)
Unlike the concat function in MySQL, the concat_ws function does not return NULL because of the NULL value when it is executed
Mysql > selectconcat_ws (',','11,'11,'11,'11,'11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,','11,') +-- + | concat_ws (',','11 records, 22 records, null) | +-- + | 11 minutes 22 | +-+ 1rowinset (0.00sec)
Thank you for your reading, these are the contents of "MySQL string concatenation function usage". After the study of this article, I believe you have a deeper understanding of what the MySQL string concatenation function usage has, and the specific use still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.