The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

There are two wildcards often used in conjunction with the LIKE operator:

SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern

% wildcard

Start with

Select all customers that starts with the letter "a":

SELECT * FROM Customers
WHERE CustomerName LIKE '**a%'**

Contain

Select all customers from a city that contains the letter ‘L’:

SELECT * FROM Customers
WHERE city LIKE **'%L%'**;

End with

To return records that ends with a specific letter or phrase, add the % at the beginning of the letter or phrase.

SELECT CustomerName FROM Customers
WHERE CustomerName LIKE **'%a'**;

_ wildcard

The _ wildcard represents a single character.

It can be any character or number, but each _ represents one, and only one, character.

SELECT * FROM Customers
WHERE city LIKE `L_nd__`