LIKE and REGEXP Operators

LIKE and REGEXP Operators

  • The LIKE keyword is used with the WHERE clause.
  • The LIKE keyword and can use two symbols as wildcards. The percent ( % ) symbol matches any number of characters and the underscore ( _ ) matches a single character
  • REGEXP keyword allows you to do more complex pattern matching than a LIKE keyword/
  • Some version of REGEXP exists in many computer languages. Refer to the “LIKE and REGEXP” handout for a full list of examples.

Table 2. LIKE Keyword

LIKE Symbol



Match any string of characters to the left of the symbol


Match a single character

Code Example:

USE world;
FROM country
WHERE name LIKE ‘A%’



Table 3. REXEXP Keyword

REGEXP Characters



Match the pattern to the beginning of the value being tested.


Match the pattern to the end of the value being tested.


Matches any single character.


Matches any single character listed within the brackets.

[char1 – char2]

Matches any single character within the given range.


Separates two string patterns and matches either one

Code Example:

USE world;
FROM country
WHERE name REGEXP 'g[o,u]';



CC BY-NC-ND International 4.0

CC BY-NC-ND International 4.0: This work is released under a CC BY-NC-ND International 4.0 license, which means that you are free to do with it as you please as long as you (1) properly attribute it, (2) do not use it for commercial gain, and (3) do not create derivative works.

End-of-Chapter Survey

: How would you rate the overall quality of this chapter?
  1. Very Low Quality
  2. Low Quality
  3. Moderate Quality
  4. High Quality
  5. Very High Quality
Comments will be automatically submitted when you navigate away from the page.
Like this? Endorse it!