SQL · Pattern 3 — Built-in Functions
LENGTH / CHAR_LENGTH
LENGTH() (MySQL/PostgreSQL/Oracle) or LEN() (SQL Server) returns how many characters are in a string — useful for validation rules or, here, filtering rows by name length.
Source data — Pattern 3: Built-in Functions
All queries run against the shared employees table (see schema.sql). This pattern needs two columns not used before: hire_date (topic 17) and bonus, nullable (topics 19–20).

What it does
LENGTH() (MySQL/PostgreSQL/Oracle) or LEN() (SQL Server) returns how many characters are in a string — useful for validation rules or, here, filtering rows by name length. CHAR_LENGTH() is the standard-SQL alias that's explicit about counting characters rather than bytes.
Problem
Find employees whose names contain more than 8 characters.
SELECT first_name,
last_name,
LENGTH(CONCAT(first_name, ' ', last_name)) AS name_length
FROM employees
WHERE LENGTH(CONCAT(first_name, ' ', last_name)) > 8;
Result
