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');NULL among the arguments
MySQL 8.1
SELECT CONCAT('sql', NULL);Name and status in one string
MySQL 8.1
SELECT CONCAT(member_name, ' (', status, ')') AS member
FROM FamilyMembers;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.