skip to main content
Operators : Comparison operators : ESCAPE clause in LIKE operator
 

ESCAPE clause in LIKE operator

Syntax 

LIKE 'pattern string' ESCAPE 'c'
The ESCAPE clause is supported in the LIKE operator to indicate the escape character. Escape characters are used in the pattern string to indicate that any wildcard character that occurs after the escape character in the pattern string should be treated as a regular character.
The default escape character is backslash (\)

Example 

SELECT * FROM emp WHERE ENAME LIKE 'J%$_%' ESCAPE '$';
This matches all records with names that start with letter ’J’ and have the ’_’ character in them.
SELECT * FROM emp WHERE ENAME LIKE 'JOE$_JOHN' ESCAPE '$';
This matches only records with name ’JOE_JOHN’.