What are SQL string functions?
Why Interviewers Ask This
Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.
Answer
MySQL provides many built-in string functions for manipulating text data: CONCAT(s1, s2, ...) — concatenate strings: CONCAT(first_name, " ", last_name); CONCAT_WS(sep, s1, s2) — concatenate with separator, skips NULLs; LENGTH(s) — byte length; CHAR_LENGTH(s) — character count (use this for multibyte characters); UPPER(s) / LOWER(s) — change case; TRIM(s) — remove leading/trailing spaces; LTRIM(s) / RTRIM(s) — left/right trim; SUBSTRING(s, pos, len) — extract substring: SUBSTRING(email, 1, LOCATE("@", email) - 1); LEFT(s, n) / RIGHT(s, n) — leftmost/rightmost n characters; LOCATE(substr, str) — position of substring (0 if not found); REPLACE(str, from, to) — replace all occurrences; LPAD(s, len, pad) / RPAD() — pad string to length; REVERSE(s); FORMAT(n, d) — format number with commas: FORMAT(1234567.89, 2) → "1,234,567.89"; REGEXP_REPLACE() (MySQL 8.0+) — replace using regex.
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real MySQL / SQL project.
Previous
What is the difference between soft delete and hard delete?
Next
What are SQL date and time functions?