Challenge - 5 Problems
CONCAT Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediateOutput 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
intermediateUsing 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
advancedIdentify 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
advancedOptimizing 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
expertBehavior 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.
