sql-server

7 Post

oracle

7 Post

postgresql

10 Post

my-sql

2 Post

common-sql

1 Post

News

5 News

In MySQL, the CONCAT() function joins (concatenates) multiple strings into one.

CONCAT(str1, str2, ..., strN)

Return value

  • Returns a single string formed by joining all input strings.
  • If any argument is NULL, the result is NULL.

Examples

Simple concatenation

SELECT CONCAT('Hello', ' ', 'World');

Result: Hello World

Important behavior (NULL)

SELECT CONCAT('Hello', NULL, 'World');

Result:NULL

If you want to ignore NULL values, use:

CONCAT_WS(separator, str1, str2, ...)

Example:

SELECT CONCAT_WS(' ', 'Hello', NULL, 'World');

Result:

Hello World