Challenge - 5 Problems
CONCAT Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of CONCAT with NULL values
What is the output of this MySQL query?
SELECT CONCAT('Hello', NULL, 'World');MySQL
SELECT CONCAT('Hello', NULL, 'World');
Attempts:
2 left
💡 Hint
Remember how CONCAT treats NULL values in MySQL.
✗ Incorrect
In MySQL, CONCAT returns NULL if any argument is NULL.
❓ query_result
intermediate2:00remaining
Using CONCAT_WS with NULL values
What is the output of this MySQL query?
SELECT CONCAT_WS('-', '2024', NULL, '06', '15');MySQL
SELECT CONCAT_WS('-', '2024', NULL, '06', '15');
Attempts:
2 left
💡 Hint
CONCAT_WS skips NULL values instead of treating them as strings.
✗ Incorrect
CONCAT_WS skips NULL values and does not add separators for them.
📝 Syntax
advanced2:00remaining
Identify the syntax error in CONCAT usage
Which option contains a syntax error in using CONCAT in MySQL?
Attempts:
2 left
💡 Hint
Look for missing arguments or commas.
✗ Incorrect
Option B has two commas with no argument between them, causing a syntax error.
❓ optimization
advanced2:00remaining
Optimizing string concatenation with CONCAT_WS
You want to concatenate first name, middle name, and last name with spaces between them. Middle name can be NULL. Which query is the most efficient and correct to avoid extra spaces?
Attempts:
2 left
💡 Hint
Think about how NULL values and separators are handled.
✗ Incorrect
CONCAT_WS skips NULL values and adds the separator only between non-NULL values, avoiding extra spaces.
🧠 Conceptual
expert2:00remaining
Behavior difference between CONCAT and CONCAT_WS
Which statement correctly describes the difference between CONCAT and CONCAT_WS in MySQL?
Attempts:
2 left
💡 Hint
Think about how each function treats NULL values.
✗ Incorrect
CONCAT returns NULL if any argument is NULL, but CONCAT_WS skips NULL arguments and concatenates the rest.