string

CONCAT

Joins two or more strings end-to-end and returns a single string. CONCAT is portable across MySQL, Postgres 9.1+, and SQLite 3.44+; the standard || operator works in Postgres and SQLite but not MySQL unless PIPES_AS_CONCAT is set.

CONCAT(str1, str2, ...)  |  str1 || str2 (Postgres/SQLite)

Parameters / Modifiers

Parameter Purpose
CONCAT_WS(sep, ...) Concatenate with a separator, skipping NULLs (MySQL, Postgres)
|| SQL-standard concat operator in Postgres/SQLite
FORMAT(fmt, ...) Postgres printf-style formatter that also concatenates

Examples

SELECT CONCAT(first_name, ' ', last_name) FROM users;

Full name string per user

SELECT first_name || ' ' || last_name FROM users;

Same result in Postgres/SQLite using ||

SELECT CONCAT_WS('-', '2026','07','16');

Returns '2026-07-16', skipping any NULL argument

SELECT CONCAT('x', NULL, 'y');

MySQL returns NULL; Postgres returns 'xy' (CONCAT ignores NULLs)

Dialect notes / Gotcha

Behaviour with NULL differs: MySQL CONCAT returns NULL if any arg is NULL, Postgres CONCAT ignores NULLs. The || operator in MySQL means logical OR by default — use CONCAT instead.

Related functions

← All SQL functions · SQL cheat sheet · Window functions · PostgreSQL cheat sheet