Skip to main content
SQL • LESSON 137

TRIM

How can we remove accidental leading and trailing whitespace?

Advanced3 Minutes1500 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