Home > Database > Mysql Tutorial > body text

How to use mysql concat() function

青灯夜游
Release: 2022-06-21 16:39:28
Original
16790 people have browsed it

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, ... );
Copy after login

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');
Copy after login

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');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!