Challenge - 5 Problems
Trim Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of TRIM function on padded string
What is the output of the following MySQL query?
SELECT TRIM(' Hello World ') AS trimmed_text;MySQL
SELECT TRIM(' Hello World ') AS trimmed_text;
Attempts:
2 left
💡 Hint
TRIM removes spaces from both sides of the string.
✗ Incorrect
The TRIM function removes leading and trailing spaces from the string, so the output is 'Hello World' without spaces on either side.
❓ query_result
intermediate2:00remaining
Output of LTRIM on string with leading spaces
What will this MySQL query return?
SELECT LTRIM(' DataBase') AS left_trimmed;MySQL
SELECT LTRIM(' DataBase') AS left_trimmed;
Attempts:
2 left
💡 Hint
LTRIM removes spaces only from the left side.
✗ Incorrect
LTRIM removes only the spaces on the left side of the string, so the output is 'DataBase' without leading spaces.
📝 Syntax
advanced2:00remaining
Identify the syntax error in RTRIM usage
Which option contains a syntax error when using RTRIM in MySQL?
Attempts:
2 left
💡 Hint
Check the function call syntax with parentheses.
✗ Incorrect
RTRIM requires parentheses around the string argument. Option D misses parentheses, causing a syntax error.
❓ query_result
advanced2:00remaining
Result of nested TRIM functions
What is the output of this query?
SELECT TRIM(TRAILING 'x' FROM LTRIM('xxxHello Worldxxx')) AS result;MySQL
SELECT TRIM(TRAILING 'x' FROM LTRIM('xxxHello Worldxxx')) AS result;
Attempts:
2 left
💡 Hint
LTRIM removes spaces, not 'x'. TRIM with TRAILING removes 'x' only from the right side.
✗ Incorrect
LTRIM does not remove 'x' characters, so the string remains 'xxxHello Worldxxx'. TRIM(TRAILING 'x' FROM ...) removes 'x' only from the right end, leaving 'xxxHello World'.
🧠 Conceptual
expert2:00remaining
Understanding difference between TRIM, LTRIM, and RTRIM
Given the string ' SQL Query ', which function(s) will remove spaces only from the right side?
Choose the correct statement.
Choose the correct statement.
Attempts:
2 left
💡 Hint
Think about what each function does: left, right, or both sides.
✗ Incorrect
RTRIM removes spaces only from the right side of the string. LTRIM removes from the left, and TRIM removes from both sides.