Beginner

366. LIKE Starts With

Learn how to find text values that begin with a specific pattern.

📘 Lesson 366 of 728 ⏱ 8 min 🎯 Beginner

A LIKE pattern ending with % can be used to find text values that start with a specified sequence of characters.

Prefix searches are useful when identifying names, codes, account prefixes, product identifiers, or locations that begin with known text.

Find employees whose names start with 'S'.

SQL
SELECT
    EmployeeName
FROM Employees
WHERE EmployeeName LIKE 'S%';

It is useful for searching customer names, product codes, branch identifiers, and other text-based business fields.

  • The pattern starts with the required characters.
  • % allows additional characters after the prefix.
  • It is useful for prefix searches.
  • LIKE behavior can depend on database collation.
  • Indexes may be usable for some prefix searches.
How do you find names starting with S?

Use WHERE EmployeeName LIKE 'S%'.

What does S% mean?

It means the text starts with S followed by zero or more characters.

Have you finished this lesson?

Introduction to SQL – All Lessons