0
0
MySQLquery~5 mins

TRIM, LTRIM, RTRIM in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the TRIM function do in MySQL?
TRIM removes spaces or specified characters from both the beginning and the end of a string.
Click to reveal answer
beginner
How does LTRIM differ from TRIM?
LTRIM removes spaces only from the left (start) side of a string.
Click to reveal answer
beginner
What is the purpose of RTRIM in MySQL?
RTRIM removes spaces only from the right (end) side of a string.
Click to reveal answer
beginner
Write a MySQL query to remove spaces from both ends of the string ' hello '.
SELECT TRIM(' hello ') AS trimmed_string; -- Result: 'hello'
Click to reveal answer
intermediate
Can TRIM remove characters other than spaces? How?
Yes, TRIM can remove other characters by specifying them. For example, TRIM(BOTH 'x' FROM 'xxhelloxx') removes 'x' from both ends.
Click to reveal answer
Which function removes spaces only from the start of a string in MySQL?
ALTRIM
BRTRIM
CTRIM
DSUBSTR
What will SELECT TRIM(' data ') return?
A'data '
B' data'
C' data '
D'data'
Which function removes spaces only from the right side of a string?
ARTRIM
BLTRIM
CTRIM
DLEFT
How do you remove the character 'x' from both ends of 'xxhelloxx' in MySQL?
ATRIM('xxhelloxx')
BLTRIM('xxhelloxx')
CTRIM(BOTH 'x' FROM 'xxhelloxx')
DRTRIM('xxhelloxx')
If you want to remove spaces only from the right side of a string, which function should you use?
ALTRIM
BRTRIM
CTRIM
DREPLACE
Explain the difference between TRIM, LTRIM, and RTRIM functions in MySQL.
Think about which side of the string each function affects.
You got /3 concepts.
    How can you use TRIM to remove a specific character other than space from a string?
    TRIM is flexible and can remove characters you specify.
    You got /3 concepts.