String Functions & Operations: Functions
Module: SQL Fundamentals
SELECT first_name || ' ' || last_name AS full_name
FROM employees;
SELECT
UPPER(email) AS email_upper,
LOWER(department) AS dept_lower
FROM employees;
SELECT
SUBSTRING(phone, 1, 3) AS area_code,
LENGTH(description) AS desc_length
FROM products;
SELECT * FROM customers
WHERE email LIKE '%@gmail.com';
Concatenation: || (PostgreSQL/Oracle), CONCAT() (MySQL), + (SQL Server)
LIKE patterns: % (any characters), _ (one character)
String functions are case-sensitive by default
NULL concatenation returns NULL (use COALESCE)
Position/Index 1-based, not 0-based
Core references in this topic include CONCAT, SUBSTRING, TRIM. Learn what each one does, when to use it, and the execution or engine rules that matter.
CONCAT
Builds a string from multiple values.
CONCAT(first_name, ' ', last_name)
SUBSTRING
Extracts part of a string based on starting position and length.
SUBSTRING(email FROM 1 FOR 5)
TRIM
Removes leading and trailing characters, commonly whitespace.
TRIM(customer_name)
UPPER / LOWER
Normalizes text casing for comparisons and presentation.
UPPER(country_code)
REPLACE
Substitutes one substring with another inside a string value.
REPLACE(phone, '-', '')
LENGTH
Returns the number of characters in a string value.
LENGTH(product_name)
WHERE
Filters rows before projection and sorting. It decides which rows continue through the query pipeline.
SELECT ... FROM table WHERE condition;
Most performance issues start with a weak WHERE clause or a missing supporting index.