SQLite 3 reference · String Functions
SQLite || Concatenation Operator
Join strings with the || operator, the standard SQL way to concatenate. If either side is NULL, the result is NULL.
SQLite 3
Syntax
X || Y
Parameters
| Parameter | Description |
|---|---|
X, Y |
Values to join; numbers are converted to text. |
Return value
The joined text, or NULL.
Examples
SELECT name || ' (' || country || ')' AS label
FROM customers
LIMIT 3;
Output
label Ada Lovelace (UK) Alan Turing (UK) Grace Hopper (USA)
SELECT name || ', ' || city AS with_city,
name || ', ' || coalesce(city, 'unknown') AS safe
FROM customers
WHERE customer_id = 7;
Output
with_city | safe NULL | Barbara Liskov, unknown
In other languages
||· PostgreSQL
Related
CONCAT()· Join any number of values into one string. Unlike ||, NULL arguments are skipped instead of making the result NULL.CONCAT_WS()· Join values with a separator between them, skipping NULLs. The ws stands for with separator.COALESCE()· Return the first argument that isn't NULL. The standard way to replace NULL with a default value.- SQL String Functions · tutorial