Brightlane's data cleaning step removes leading and trailing whitespace from user-submitted email addresses before they are stored.
Write a query to return the trimmed value of the string ' [email protected] '.
Output:
- A single row with one column,
clean_email, containing the trimmed string.
Schema · ecommerce 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
TRIM(' [email protected] ') AS clean_email The shape
TRIM(' [email protected] ') removes the three leading and three trailing spaces and returns '[email protected]'. The default TRIM strips spaces from both ends, which is exactly the cleanup the email-storage step needs.
Clause by clause
SELECT TRIM(' [email protected] ') AS clean_emailruns the function against the padded literal and labels the resultclean_email. With no characters argument and no side specified,TRIMdefaults to stripping spaces from both the left and the right until it hits a non-space character on each side. The interior of the string is untouched, so the email itself comes through intact.- There is no
FROMbecause the value being cleaned is the literal embedded in theSELECT. One input, one output, no table needed.
Why this and not a per-side trim
A user-submitted email could carry whitespace on either end, and TRIM with no side argument handles both at once. Reaching for LTRIM or RTRIM here would only strip one side and leave the other padding in place, which would fail the next equality check against a clean address. The default both-sides behavior is what the storage step depends on.
You practiced TRIM(...) — strip leading and trailing spaces by default; the standard preprocessing step for inbound text values.