Categories: MySQL

MySQL LIKE Operator

Share

Using MySQL LIKE operator you can search based on patterns. It is used in the WHERE clause in SELECT statement.

This basically use two characters for using the MySQL LIKE operator:

‘%’ – allows you to match zero or more characters
‘_’ – allows you to match any single character

For searching the first character starts with ‘a’ like andy, arnold:
SELECT * FROM users WHERE name LIKE ‘a%’;

For searching the last character ends with ‘ck’ like jack, drack:
SELECT * FROM users WHERE name LIKE ‘%ck’;

For searching the middle character with ‘ac’ like jack, drack:
SELECT * FROM users WHERE name LIKE ‘%ac%’;

For searching the name whose name starts with P and ends with m like pom, pim:
SELECT * FROM users WHERE name LIKE ‘p_m’;

You can also use NOT operator to like for exception:
SELECT * FROM users WHERE name NOT LIKE ‘a%’;

Recent Posts

Warm Comfort: Choosing the Best Hot Water Bottle for Cozy Nights

Introduction: As the chill of winter settles in or a bout of cold weather strikes,…

16 hours ago

One Location, Different Perspectives: The Allure of Dubai Marina Apartments

Nestled along the glittering waterfront of the City of Gold, Dubai Marina beckons to discerning…

16 hours ago

Role Of Gojek Clone In Growth Campaigns For Your Business

When was the last time you heard that a clone app like Gojek could efficiently…

22 hours ago

How to Optimize Your E-Commerce Pages and Improve UX?

The e-commerce market is growing and evolving at a rapid pace. More and more people…

1 day ago

What Not to Do When Navigating Through a Personal Injury Claim?

Navigating through a personal injury claim can be a complex and daunting process. If you've…

2 days ago

Overview of Reputation, Services, and Features of IplWin

IplWin stands as a reliable and enthralling platform for Indian punters, offering a captivating blend…

4 days ago