PostgreSQL 18 reference · String Functions
PostgreSQL CONCAT() Function
Join any number of values into one string, treating NULL arguments as empty strings.
PostgreSQL 18 Since 9.1
Syntax
concat(val1, val2, ...)
Parameters
| Parameter | Description |
|---|---|
val |
Values of any type. |
Return value
Text (never NULL).
Examples
SELECT concat('Order #', order_id, ' - ', status) AS label
FROM orders
LIMIT 2;
Output
label ---------------------- Order #1 - delivered Order #2 - delivered (2 rows)
Run this on your computer — see “Get Started” for setup.
SELECT concat('a', NULL, 'b', 42) AS result;
Output
result -------- ab42 (1 row)
Run this on your computer — see “Get Started” for setup.
Version history
| Version | Change |
|---|---|
| PostgreSQL 9.1 | Added |
In other languages
CONCAT()· SQLite
Related
CONCAT_WS()· Join values with a separator between them, skipping NULLs. The first argument is the separator.||· Join strings with the || operator. If either side is NULL the result is NULL; use concat() to skip NULLs instead.FORMAT()· Build a string from a template: %s inserts text, %I a quoted identifier and %L a quoted literal, for safe dynamic SQL.- SQL String Functions · tutorial