Skip to main content Skip to complementary content

The "like" operator

The like operator allows you to check if a value matches a pattern. It can be used with the operator not to check if a value does not match the pattern specified. The expression is structured as follows:
value like pattern
You can use the following wildcards in the pattern:
Symbol Description Example
% Matches zero or more characters. Pattern: "bl%"
  • Matches: "black", "blue"
  • Does not match: "able"
_ Matches a single character. Pattern: "h_t"
  • Matches: "hit", "hat"
  • Does not match: "heat"
[] Matches any single character within the brackets. Pattern: "b[ae]t"
  • Matches: "bat", "bet"
  • Does not match: "beat"
[start-end] Matches any single character within the specified range. Pattern: "[b-d]at"
  • Matches: "bat", "cat", "dat"
  • Does not match: "data"
[^characters] Matches any character not in the brackets. Pattern: "h[^oa]t"
  • Matches: "hit", "hut"
  • Does not match: "hot", "hat"

Examples

Clause Result
WHERE name LIKE "a%"
Returns any element where the value of name starts with a.
WHERE name LIKE "%a"  
Returns any element where the value of name ends with a.
WHERE name LIKE "%bir%" 
Returns any element where the value of name contains bir.
WHERE name LIKE "_r%"
Returns any element where the second character of the value of nameis r.
WHERE name LIKE "a__%"
Returns any element where value of name starts with a, followed by at least two characters.
WHERE name LIKE "a%o"
Returns any element where value of name starts with a and ends with o.
WHERE name NOT LIKE "%[A-Z]"
Returns any element where value of name does not end with a capital letter.
WHERE name NOT LIKE "%[^0-9]%"
Returns any element where value of name only contains numbers.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!