CONCAT() FUNCTION in MySQL

CONCAT() FUNCTION
The MySQL CONCAT function is used to concatenate two or more expressions together. The various versions of MySQL support the CONCAT function, namely, MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0 and MySQL 3.23.

Syntax:

CONCAT( expr_1, expr_2, ... expr_n )

Parameters:

expr_1, expr_2, … expr_n: It is used to specify the expressions to concatenate.

Example 1:

mysql> SELECT CONCAT ( ‘Sum of 2 and 4 is ’, 2+4 );

Output:

‘Sum of 2 and 4 is 6’

Explanation:

The expressions are concatenated.

Example 2:

mysql> SELECT CONCAT (‘lets’, ‘be’, ‘friends’);

Output:

‘letsbefriends’

Explanation:

The expressions are concatenated.