Instruction
Great! Let's look at functions that remove leading or trailing spaces from a string.
One of these is LTRIM(). It removes the leading (left) spaces from a string.
SELECT LTRIM(' Sophie ');
This query returns 'Sophie '. The leading space was removed.
The RTRIM() function removes the trailing (right) spaces from a string. It works in a similar way:
SELECT RTRIM(' Sophie ');
This returns ' Sophie'. There is a leading space, but no trailing space.
Exercise
Some of the item names in the item table have leading spaces. Show two columns:
- The item name.
Prefix the value with'No trim:'to see the leading spaces.
Name the columnbefore_ltrim. - The item name without leading spaces.
Prefix the value with'Trim:'to make sure the spaces have been removed.
Name the columnafter_ltrim.
To add prefixes, use the concatenation operator.
Stuck? Here's a hint!
Use LTRIM(name) to remove leading spaces from the item names. Don't put any spaces at the end of the prefixes.



