Intermediate · Lesson 16 of 20

String Functions

SQL has built-in functions for working with text.

Common string functions:

  • UPPER(text) - converts to uppercase
  • LOWER(text) - converts to lowercase
  • LENGTH(text) - returns character count
  • SUBSTR(text, start, length) - extracts part of a string
  • TRIM(text) - removes leading/trailing spaces

Concatenation in SQLite uses ||:

SELECT first_name || ' ' || last_name AS full_name
FROM employees;

Example:

SELECT UPPER(first_name) || ' ' || UPPER(last_name) AS full_name
FROM employees;

String functions are essential for cleaning and formatting data.

Check your understanding

Create each employee's full name in uppercase, first and last name separated by a space.

Examples run on the employees sample database. Open any of them in the playground to experiment.