Skip to main content

CONCAT

Functions › Text › Change a string

Joins its arguments into one string. NULL arguments are skipped.

Syntax​

CONCAT( <value> [, <value> ...] )

Arguments​

ArgumentDescription
<value>One or more values to join. A number, boolean or date is joined as its text.

Returns​

Text. A NULL argument adds nothing, so the result is never NULL because of one NULL argument. When every argument is NULL the result is empty.

Usage notes​

  • The || operator also joins text, but a || b is NULL when either side is NULL. Use CONCAT when a missing part should be left out.
  • To put a separator between the parts, use CONCAT_WS.
  • To join values across rows, use STRING_AGG.
  • On large tables the engine runs it in the data store, unless an argument is a decimal number or a timestamp.

Examples​

SELECT c.key, CONCAT(c.first_name, ' ', c.last_name) AS name FROM Customer c
keyname
C-104Ana Ruiz
C-221Smith

Compared with || when a part is NULL:

SELECT o.key, CONCAT('Order ', o.number, o.suffix) AS with_concat, 'Order ' || o.number || o.suffix AS with_pipes
FROM Order o
keywith_concatwith_pipes
O-501Order 4410AOrder 4410A
O-502Order 4411NULL

See also​

CONCAT_WS · Operators · COALESCE · STRING_AGG