TRIM, LTRIM, RTRIM variations
📖 Scenario: You work in a company database where customer names sometimes have extra spaces at the start or end. These spaces cause problems when searching or sorting names.
🎯 Goal: You will create a table with customer names that include extra spaces. Then, you will write queries using TRIM, LTRIM, and RTRIM functions to clean these names by removing unwanted spaces.
📋 What You'll Learn
Create a table named
customers with a column name of type VARCHAR.Insert exactly these names with spaces:
' Alice ', ' Bob', 'Charlie ', ' Diana '.Write a query selecting all names trimmed on both sides using
TRIM.Write a query selecting all names trimmed only on the left side using
LTRIM.Write a query selecting all names trimmed only on the right side using
RTRIM.💡 Why This Matters
🌍 Real World
Cleaning up text data in databases is common to ensure consistent searching, sorting, and reporting.
💼 Career
Database administrators and developers often use trimming functions to prepare and clean data for applications.
Progress0 / 4 steps