Beginner

204. POSITION Function

Learn how to find the position of one text value inside another.

📘 Lesson 204 of 728 ⏱ 9 min 🎯 Intermediate

The POSITION function can be used in supported SQL systems to determine where a specified substring occurs within another string.

Finding text positions is useful when extracting or analyzing structured text values.

Find the position of the @ symbol in an email address.

SQL
SELECT
    Email,
    POSITION('@' IN Email) AS AtPosition
FROM Customers;

It is useful for email analysis, identifier parsing, text validation, and data cleansing.

  • POSITION searches for a substring.
  • It returns the location of the substring.
  • Syntax can vary by database.
  • It is useful for parsing text.
  • It can be combined with substring functions.
What does POSITION do?

POSITION finds the location of a specified substring within another string.

Where can POSITION be useful?

It can be useful when parsing structured text such as email addresses or identifiers.

Have you finished this lesson?

Introduction to SQL – All Lessons