To test for literal instances of a wildcard character, precede it by the escape character. : LIKE « String Functions « MySQL Tutorial






If you do not specify the ESCAPE character, '\' is assumed.

To search for '\n', specify it as '\\n'.

To search for '\', specify it as '\\\\'.

StringDescription
\%Matches one '%' character
\_Matches one '_' character


SELECT 'ABCDE!' LIKE 'ABCDE\_';
SELECT 'ABCDE_' LIKE 'ABCDE\_';








23.21.LIKE
23.21.1.expr LIKE pat [ESCAPE 'escape_char']
23.21.2.To test for literal instances of a wildcard character, precede it by the escape character.
23.21.3.To specify a different escape character, use the ESCAPE clause:
23.21.4.String comparisons are not case sensitive unless one of the operands is a binary string
23.21.5.In MySQL, LIKE is allowed on numeric expressions.