String Functions — Complete Guide
String Functions — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of MySQL Tutorial on Toolliyo Academy.
On this page
MySQL Tutorial · Lesson 32 of 100
String Functions
Basics ✓ → Advanced
Advanced · 2 — Production · ~6 min · MySQL — Functions & Window Functions
What is this?
String functions transform text: CONCAT, SUBSTRING, TRIM, UPPER, LOWER, REPLACE, LENGTH. Essential for cleaning user input and building display labels.
Why should you care?
UPI and phone search often strip spaces and +91 prefixes before matching — SQL helps batch exports.
See it live — copy this example
Run in MySQL Workbench or the mysql CLI.
SELECT customer_id,
TRIM(full_name) AS name_clean,
UPPER(city) AS city_upper,
CONCAT(full_name, ' (', city, ')') AS label
FROM customers
WHERE full_name LIKE '%sharma%';
What happened?
- TRIM removes accidental spaces.
- UPPER standardizes city for grouping.
- CONCAT builds CSV-friendly label.
- LIKE does pattern match on name.
Practice next
- Insert name with leading spaces.
- Run TRIM demo.
- Try REPLACE(full_name,' ',' ') for double spaces.
- Use REGEXP for stricter phone format.
- ORDER BY LENGTH(full_name) DESC for longest names.
Remember
Clean and format text in SELECT. LIKE for pattern search; consider FULLTEXT later. CONCAT builds derived columns.
DataFlow duplicate name cleanup
Ops exports TRIM(full_name) list to merge typo accounts before merge tool runs.
Outcome: Support queue shrinks after dedupe.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!