Brightlane's notification system builds greeting messages by combining a salutation and a recipient name.
Write a query to return the result of using CONCAT to combine 'Hello', ', ', and 'Alex' into a single string.
Output:
- A single row with one column,
greeting, containing the concatenated string.
Schema · ecommerce 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
CONCAT('Hello', ', ', 'Alex') AS greeting The shape
CONCAT('Hello', ', ', 'Alex') joins its three string arguments end-to-end in the order given and returns 'Hello, Alex'. One function call, one combined string, no separator-management logic required.
Clause by clause
SELECT CONCAT('Hello', ', ', 'Alex') AS greetingevaluates theCONCATcall and labels the resulting columngreeting.CONCATis variadic: it accepts any number of arguments and concatenates them left to right into a single string. The literal', 'is itself one of the arguments, which is how the comma and the space appear between the salutation and the name. There is noFROMbecause all three values come straight from the prompt as literals.
Why this and not 'Hello' || ', ' || 'Alex'
Both forms return 'Hello, Alex' on this input. CONCAT(a, b, c) reads as one variadic call with the parts in a list, which scales cleanly when there are four, five, or ten components to combine. The || chain reads as a sequence of binary operations and grows visually noisier with each added part. Reach for CONCAT when the operation is naturally a list of pieces rather than a pair.
You practiced CONCAT(...) with multiple arguments — variadic concatenation in one call rather than a chain of || operators.