8/16/26, 1:16 PM MySQL LIKE Operator
Tutorials References Exercises Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP [Link] C C++ C#
MySQL LIKE Operator
❮ Previous Next ❯
The MySQL LIKE Operator
The LIKE operator is used in a WHERE clause to search for a specified pattern within a
column's text data.
There are two wildcards often used in conjunction with the LIKE operator:
A percent sign % - represents zero, one, or multiple characters
A underscore sign _ - represents a single character
The percent sign and the underscore can also be used in combinations!
LIKE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
Tip: You can also combine any number of conditions using AND or OR operators.
Here are some examples showing different LIKE operators with '%' and '_' wildcards:
[Link] 1/8
8/16/26, 1:16 PM MySQL LIKE Operator
LIKE Operator
Tutorials References
Description
Exercises Sign In
WHERE CustomerName LIKE Finds any values that start with "a"
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP [Link] C C++ C#
'a%'
WHERE CustomerName LIKE Finds any values that end with "a"
'%a'
WHERE CustomerName LIKE Finds any values that have "or" in any position
'%or%'
WHERE CustomerName LIKE Finds any values that have "r" in the second position
'_r%'
WHERE CustomerName LIKE Finds any values that start with "a" and are at least 2
'a_%' characters in length
WHERE CustomerName LIKE Finds any values that start with "a" and are at least 3
'a__%' characters in length
WHERE ContactName LIKE Finds any values that start with "a" and ends with "o"
'a%o'
Demo Database
Below is a selection from the "Customers" table in the Northwind sample database:
CustomerID CustomerName ContactName Address City PostalCode C
1 Alfreds Maria Anders Obere Str. 57 Berlin 12209 G
Futterkiste
2 Ana Trujillo Ana Trujillo Avda. de la México 05021 M
Emparedados y Constitución D.F.
helados 2222
3 Antonio Moreno Antonio Mataderos México 05023 M
Taquería Moreno 2312 D.F.
[Link] 2/8
8/16/26, 1:16 PM MySQL LIKE Operator
4 Tutorials Around the Horn Thomas
References Exercises
Hardy
120 Hanover
Sq.
London WA1 1DPSign InU
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP [Link] C C++ C#
5 Berglunds Christina Berguvsvägen Luleå S-958 22 S
snabbköp Berglund 8
REMOVE ADS
SQL LIKE Examples
The following SQL selects all customers with a CustomerName starting with "a":
Example Get your own SQL Server
SELECT * FROM Customers
WHERE CustomerName LIKE 'a%';
Try it Yourself »
The following SQL selects all customers with a CustomerName ending with "a":
Example
SELECT * FROM Customers
WHERE CustomerName LIKE '%a';
Try it Yourself »
The following SQL selects all customers with a CustomerName that have "or" in any position:
[Link] 3/8
8/16/26, 1:16 PM MySQL LIKE Operator
Tutorials
Example References Exercises Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP [Link] C C++ C#
SELECT * FROM Customers
WHERE CustomerName LIKE '%or%';
Try it Yourself »
The following SQL selects all customers with a CustomerName that have "r" in the second
position:
Example
SELECT * FROM Customers
WHERE CustomerName LIKE '_r%';
Try it Yourself »
The following SQL selects all customers with a CustomerName that starts with "a" and are at
least 3 characters in length:
Example
SELECT * FROM Customers
WHERE CustomerName LIKE 'a__%';
Try it Yourself »
The following SQL selects all customers with a ContactName that starts with "a" and ends with
"o":
Example
[Link] 4/8
8/16/26, 1:16 PM MySQL LIKE Operator
SELECT * FROM Customers
Tutorials References
WHERE ContactName LIKE 'a%o';
Exercises Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP [Link] C C++ C#
Try it Yourself »
The following SQL selects all customers with a CustomerName that does NOT start with "a":
Example
SELECT * FROM Customers
WHERE CustomerName NOT LIKE 'a%';
Try it Yourself »
?
Exercise
Insert the missing parts to returns all Customers that starts with the the letter
'A'
SELECT * FROM Customers CustomerName
'A ';
= # LIKE WHERE % _ IS
Submit Answer »
❮ Previous Sign in to track progress Next ❯
[Link] 5/8
8/16/26, 1:16 PM MySQL LIKE Operator
Tutorials References Exercises Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP [Link] C C++ C#
REMOVE ADS
Create a W3Schools Account
Ad-free learning, track your progress, earn XP, streaks, compete in leagues, build
-->
and host websites, unlock coding challenges, and much more!
Earn XP Streaks Leagues
Sign Up for Free
[Link] 6/8
8/16/26, 1:16 PM MySQL LIKE Operator
Tutorials References Exercises Sign In
HTML
CSS
JAVASCRIPT
PLUS
SQL PYTHON
SPACES
JAVA PHP [Link] C C++ C#
GET CERTIFIED FOR TEACHERS
PRACTICE CONTACT US
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
AngularJS Reference
jQuery Reference
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
[Link] 7/8
8/16/26, 1:16 PM MySQL LIKE Operator
XML Examples C# Certificate
Tutorials jQuery Examples
References Exercises XML Certificate
Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP [Link] C C++ C#
FORUM ABOUT ACADEMY
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and
learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and
privacy policy.
Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by [Link].
[Link] 8/8