LIKE Operator - Migration Reference

LIKE operator allows you to search for a specified pattern in strings. LIKE supports wildcard characters.

Syntax:

  -- Pattern matching
  str [NOT] LIKE pattern [ESCAPE escape_char]

Example:

  -- Select cities with the second letter 'a' in the name
  SELECT * FROM cities WHERE name LIKE '_a%';

Supported in:

Oracle LIKE
SQL Server LIKE Non-standard wildcard characters [] and [^]

Summary:

Match substring %substring% 'abcde' LIKE '%bc%'
Any single character _ 'abcde' LIKE '%b_d%'
Any characters % 'abcde' LIKE '%b%d%'
One of characters [] 'abcde' LIKE '%[ab]%' SQL Server only
Range of characters [a-z] 'abcde' LIKE '%[c-e]%' SQL Server only

Alternatives:

Oracle REGEXP_LIKE
PostgreSQL REGEXP_LIKE Since PostgreSQL 15