LQ
SQL Reference
Practice →
SQL ReferenceFunctionsString Functions

String Functions

Transform and inspect text values.

Questions this answers
  • How do I make text uppercase or lowercase?
  • How do I extract part of a string?
  • How do I join two strings together?
  • How do I find the length of a string?
  • How do I remove whitespace from a string?

How it works

SQL has a rich set of functions for working with text. The exact function names vary slightly between databases, but the concepts are universal: transform case, extract substrings, concatenate, measure length, and trim whitespace.

Case functions

SELECT
  UPPER(name) AS upper_name,
  LOWER(name) AS lower_name
FROM artists;

Substring extraction

-- SUBSTR(string, start, length)
SELECT SUBSTR(name, 1, 3) AS first_three FROM artists;

Concatenation

SELECT name || ' — ' || genre AS label FROM artists;
💡 Use || in SQLite/PostgreSQL. Use CONCAT() in MySQL.

Length and trim

SELECT
  LENGTH(name) AS name_length,
  TRIM(name)   AS trimmed_name
FROM artists;

Ready to practise String Functions?

Solve real exercises with AI feedback — free to start.

Try it free →