Home  >  Article  >  Database  >  How to use mysql concat() function

How to use mysql concat() function

青灯夜游
青灯夜游Original
2022-06-21 16:39:2816766browse

In mysql, the concat() function is used to concatenate two or more strings into one string and return it. The syntax is "CONCAT(string1,string2, ... );"; this function At least one parameter is required, otherwise an error will occur. The concat() function converts all parameters to string type before splicing; if any parameter is NULL, the CONCAT() function returns a NULL value.

How to use mysql concat() function

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

mysql concat() function

Usage: splicing strings

concat() function Concatenates two or more strings into one string and returns it.

The CONCAT() function requires at least one parameter, otherwise an error will occur.

Syntax of CONCAT() function.

CONCAT(string1,string2, ... );

The CONCAT() function converts all parameters to string type before concatenation. If any argument is NULL, the CONCAT() function returns a NULL value.

Example: Splicing two strings MySQL and CONCAT

SELECT CONCAT('MySQL','CONCAT');

How to use mysql concat() function

If you add a NULL value, the CONCAT function will return a NULL value, as shown below:

SELECT CONCAT('MySQL',NULL,'CONCAT');

How to use mysql concat() function

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to use mysql concat() function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn