Function Reference

CONCAT

Joins the arguments into one string.

MySQL 8.1
CONCAT(str[, ...])

Parameters

strVARCHAR
String to join, a number is converted to a string

Return value

A string; NULL if any argument is NULL

Examples

Joining three strings

MySQL 8.1
SELECT CONCAT('sql', '-', 'academy');
CONCAT('sql', '-', 'academy')
sql-academy

NULL among the arguments

MySQL 8.1
SELECT CONCAT('sql', NULL);
CONCAT('sql', NULL)
<NULL>

Name and status in one string

MySQL 8.1
SELECT CONCAT(member_name, ' (', status, ')') AS member
FROM FamilyMembers;
member
Headley Quincey (father)
Flavia Quincey (mother)
Andie Quincey (son)
Lela Quincey (daughter)
Annie Quincey (daughter)
Ernest Forrest (father)
Constance Forrest (mother)
Wednesday Addams (daughter)

Details

To keep a single NULL from turning the whole result into NULL, replace it with an empty string using IFNULL or join the strings with CONCAT_WS, which skips NULL.

See also

Where to learn