CodeBlanks Logo Icon CodeBlanks

CONCAT

Join strings with CONCAT.

CONCAT

With CONCAT you join texts. The || operator does the same.

SELECT CONCAT(name, ' ', city) AS etiket FROM customers;

This query joins name and city with a space between.

CONCAT(name, ' ', city) AS etiket is selected from customers.

CONCAT — details

CONCAT treats NULL as empty text; || returns NULL if any operand is NULL. This difference matters.

Practice CONCAT

Join name and city with a space as label from customers.

Starter code

query.sql
-- join texts
SELECT
FROM customers

Sample solution

query.sql
SELECT CONCAT(name, ' ', city) AS etiket
FROM customers

Expected output

etiket
Ayşe İstanbul
Alex Berlin

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Concatenate

Question
SELECT ____(name, ' ', city) FROM customers;
Answer
SELECT CONCAT(name, ' ', city) FROM customers;

Explanation: CONCAT joins the given texts in order; ' ' between them adds a space.

2 CONCAT: match the terms

Term Meaning
CONCAT join
|| operator
UPPER uppercase
LENGTH length

3 Which joins texts?

  • AVG
  • SUM
  • CONCAT Correct answer
  • COUNT

Explanation: CONCAT joins texts.

All lessons in Beginner