Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the CONCAT () function in MySQL

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to use CONCAT() function in MySQL", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how to use CONCAT() function in MySQL" this article bar.

CONCAT()

CONCAT(str1,str2,…) returns a string after concatenation of multiple strings, for example:

SELECT CONCAT ('MySQL ', ' string','function') AS str;str |----------------+MySQL string function|

If any of the arguments in this function are NULL, the return result is NULL. For example:

SELECT CONCAT ('MySQL ', NULL, ' function') AS str;str|---+ |

For string constants, we can also concatenate them directly. For example:

SELECT 'MySQL' 'string' 'function' AS str;str |----------------+MySQL string function|

The above method can only be used to connect string constants, not to connect field values.

? If SQL mode PIPES_AS_CONCAT is enabled, MySQL logical OR operator (||It can also be used for connection strings, similar to Oracle and PostgreSQL.

In addition to the CONCAT(str1,str2,…)) function, the CONCAT_WS(separator,str1,str2,…)) function represents concatenation of multiple strings using the specified separator, which returns NULL. For example:

SELECT CONCAT_WS ('-', 'MySQL', NULL, ' string') AS str1, CONCAT_WS(NULL, 'MySQL', 'string') AS str2;str1 |str2|-------------+----+MySQL-String| |The above is "how to use CONCAT() function in MySQL" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report