Using LIKE Conditions in MySQL

Q

How To Use LIKE Conditions in MySQL?

✍: FYIcenter.com

A

A LIKE condition is also called pattern patch. There are 3 main rules on using LIKE condition:

  • '_' is used in the pattern to match any one character.
  • '%' is used in the pattern to match any zero or more characters.
  • ESCAPE clause is used to provide the escape character in the pattern.

The following tutorial exercise provides you some good pattern matching examples:

SELECT 'FYIcenter.com' LIKE '%center%' FROM DUAL;
   1

SELECT 'FYIcenter.com' LIKE '%CENTER%' FROM DUAL;
   1
   -- Case insensitive by default

SELECT 'FYIcenter.com' LIKE '%CENTER_com' FROM DUAL;
   1

 

Using Regular Expression with REGEXP in MySQL

Using IN Conditions in MySQL

Introduction to SQL Basics in MySQL

⇑⇑ MySQL Database Tutorials

2018-03-24, 1248🔥, 0💬