0
0
MySQLquery~20 mins

TRIM, LTRIM, RTRIM in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Trim Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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;
A' Hello World '
B'Hello World'
C'Hello World '
D' Hello World'
Attempts:
2 left
💡 Hint
TRIM removes spaces from both sides of the string.
query_result
intermediate
2: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;
A'DataBase'
B'DataBase '
C' DataBase'
D'Data Base'
Attempts:
2 left
💡 Hint
LTRIM removes spaces only from the left side.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in RTRIM usage
Which option contains a syntax error when using RTRIM in MySQL?
ASELECT RTRIM('Test String ') AS trimmed;
BSELECT RTRIM('Test String ') trimmed;
CSELECT RTRIM('Test String ') AS trimmed_string;
DSELECT RTRIM 'Test String ' AS trimmed;
Attempts:
2 left
💡 Hint
Check the function call syntax with parentheses.
query_result
advanced
2: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;
A'xxxHello World'
B'Hello Worldxxx'
C'xxHello World'
D'Hello World'
Attempts:
2 left
💡 Hint
LTRIM removes spaces, not 'x'. TRIM with TRAILING removes 'x' only from the right side.
🧠 Conceptual
expert
2: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.
ATRIM removes spaces only from the right side.
BLTRIM removes spaces only from the right side.
CRTRIM removes spaces only from the right side.
DLTRIM and RTRIM both remove spaces only from the right side.
Attempts:
2 left
💡 Hint
Think about what each function does: left, right, or both sides.