Part 101: String Functions: CONCAT, SUBSTRING, LENGTH, TRIM & CASE
Manipulating textual data directly inside queries.
1. Common String Functions
SELECT
-- Concatenation:
CONCAT(first_name, ' ', last_name) AS full_name,
first_name || ' ' || last_name AS full_name_pipe_syntax,
-- Trimming whitespace:
TRIM(' spaced text ') AS clean_text,
-- Case transformations:
LOWER(email) AS normalized_email,
UPPER(country_code) AS country_code,
-- Substrings and Length:
LENGTH(username) AS char_count,
SUBSTRING(email FROM 1 FOR 5) AS prefix
FROM users;
Key Takeaways
- Clean, normalize, and concatenate strings within the database before returning to client apps.
In Part 102, we explore Advanced String Manipulation: REPLACE, LPAD, RPAD & STRPOS!

