Skip to main content
SQL โ€ข LESSON 137

TRIM

How can we remove accidental leading and trailing whitespace?

Advancedโฑ 3 Minutesโญ 1500 XP
๐Ÿค” THE QUESTION

How can we remove accidental leading and trailing whitespace?

๐Ÿ’ก WHAT IS IT?

TRIM() removes leading and trailing spaces from text fields.

๐ŸŽฏ WHAT IS IT USED FOR?

Cleaning user form inputs, stripping whitespace from CSV ingestion, data hygiene.

๐Ÿ’ป EXAMPLE
SELECT
TRIM(name) AS cleaned_name
FROM employees;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for TRIM.

  • โœ“ TRIM() function
  • โœ“ Whitespace removal
  • โœ“ Data cleaning
  • โœ“ Input sanitization