Beginner

368. LIKE Contains

Learn how to find text values containing a specific sequence of characters.

📘 Lesson 368 of 728 ⏱ 8 min 🎯 Beginner

A LIKE pattern with % on both sides searches for a specified sequence anywhere within the text.

Contains searches are useful when the exact position of the text is unknown.

Find customer names containing the word 'Kumar'.

SQL
SELECT
    CustomerName
FROM Customers
WHERE CustomerName LIKE '%Kumar%';

This is useful for customer searches, address searches, product descriptions, issue descriptions, and text-based data validation.

  • % before and after a pattern allows text on both sides.
  • The pattern can occur anywhere in the value.
  • It is useful for partial text searches.
  • Contains searches can be slower on large datasets.
  • Full-text search may be better for advanced text searching.
How do you search for text anywhere in a value?

Use LIKE with percent wildcards on both sides, such as LIKE '%Kumar%'.

Why can contains searches be slower?

A leading wildcard can prevent efficient use of a normal index in many database systems.

Have you finished this lesson?

Introduction to SQL – All Lessons