Recall & Review
beginner
What does the || operator do in PostgreSQL?
The || operator joins two or more strings together into one combined string.
Click to reveal answer
beginner
Write a simple example using || to join 'Hello' and 'World'.
SELECT 'Hello' || ' ' || 'World'; -- Result: 'Hello World'
Click to reveal answer
intermediate
Can you use || to concatenate NULL with a string? What happens?
If any part is NULL, the whole result becomes NULL. Use COALESCE to avoid this.
Click to reveal answer
intermediate
How to safely concatenate a nullable column with a string?
Use COALESCE(column, '') to replace NULL with empty string before concatenation.
Click to reveal answer
beginner
Is the || operator specific to PostgreSQL or standard SQL?
The || operator is part of the SQL standard for string concatenation and supported by PostgreSQL.
Click to reveal answer
What is the result of SELECT 'Hi' || ' ' || 'There';?
✗ Incorrect
The || operator joins strings with no added spaces unless you add them explicitly.
What happens if you concatenate 'Hello' || NULL in PostgreSQL?
✗ Incorrect
Concatenating with NULL results in NULL unless handled with COALESCE.
Which function helps avoid NULL results when concatenating nullable columns?
✗ Incorrect
COALESCE() replaces NULL with a specified value, like an empty string.
Is || operator used for arithmetic addition or string concatenation?
✗ Incorrect
In PostgreSQL, || joins strings together.
Which of these is a valid way to concatenate first_name and last_name with a space?
✗ Incorrect
Both || operator and CONCAT_WS function can concatenate strings with spaces.
Explain how to concatenate two strings in PostgreSQL and handle NULL values safely.
Think about what happens if one string is missing.
You got /3 concepts.
Describe the difference between using || operator and CONCAT_WS function for string joining.
Consider how spaces or separators are added.
You got /3 concepts.