Lesson 4 of 13 · 20 min

String functions

By the end of this lesson you can normalise text (case and spaces), extract parts of a string by delimiter or position, and build display text that survives NULLs.

To a database, 'Riyadh', 'riyadh' and ' Riyadh' are three different values. They do not group together, they do not join, and WHERE city = 'Riyadh' finds only the first. People see one city; SQL sees three strings. String functions close that gap.

They fall into three families: functions that normalise text, functions that take text apart, and functions that put text together.

Included with a Formula Quest membership

This lesson, its 4 graded exercises and every other Members lesson in SQL Quest come with a Formula Quest membership that includes SQL (Single Quest with SQL selected, Quest Trio including SQL, or Quest Unlimited), or with SQL access from your organization.

Free to everyone: all of SQL Foundations and Retrieving and Filtering Data, the first lesson of every track, the playground, the dataset library and the SQL reference. See free lessons