</>
Skip to content
SQL lessons (19/54)

SQL — Like

Basic LIKE

-- Starts with
SELECT * FROM users WHERE name LIKE 'A%';

-- Ends with
SELECT * FROM users WHERE name LIKE '%son';

-- Contains
SELECT * FROM users WHERE name LIKE '%li%';

Wildcards

-- % matches any string
SELECT * FROM users WHERE email LIKE '%@gmail.com';

-- _ matches single character
SELECT * FROM users WHERE phone LIKE '___-___-____';

NOT LIKE

SELECT * FROM users WHERE name NOT LIKE 'A%';

Case-insensitive

-- MySQL
SELECT * FROM users WHERE name LIKE '%alice%';

-- PostgreSQL
SELECT * FROM users WHERE name ILIKE '%alice%';

ESCAPE

-- Find 10% discount
SELECT * FROM products WHERE description LIKE '%10!%%' ESCAPE '!';

Mini Practice

Write SQL code that:

  1. Uses LIKE with % wildcard
  2. Uses LIKE with _ wildcard
  3. Uses NOT LIKE
  4. Uses ESCAPE for special characters

Up Next

In the next lesson, you'll learn about Between — range filtering.

Related Topics

Frequently Asked Questions about Like

What is Like in SQL?

Like is a fundamental concept in SQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Like?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Like.

Why is Like important in SQL?

Like is essential for SQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.