Trim Whitespace in SQL

Level 122 keystrokes

TRIM function removes leading and trailing whitespace from a string.

SQL code

-- TRIM removes spaces at the start and end of the string
-- ' hi ' becomes 'hi'; spaces inside the string are kept
1SELECT TRIM(' hi ');

Output

+----------------+
| TRIM('  hi  ') |
+----------------+
| hi             |
+----------------+
1 row in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • '× 2
  • ;× 1
  • (× 1
  • )× 1

More SQL examples at level 1

← SQL typing practice