SQL || and CONCAT
Join text values together.
Syntax
text1 || text2 CONCAT(text1, text2, …)
SQLite and PostgreSQL use ||. If any part is NULL, the whole result is NULL (wrap parts in COALESCE).
Example
Query (on the shop database used in the SQL course)
SELECT name || ' (' || country || ')' AS label FROM customers LIMIT 4;
Result
| label |
|---|
| Aarav Sharma (New Zealand) |
| Mia Chen (Australia) |
| Liam Walker (Australia) |
| Sita Gurung (Australia) |
4 rows
Good to know. MySQL and SQL Server use CONCAT (PostgreSQL has it too).
Related
Learn it step by step in the free lesson Functions: Text, Numbers, Dates & CASE, with exercises that check your queries.