expr LIKE pat [ESCAPE 'escape_char'] : LIKE « String Functions « MySQL Tutorial






Pattern matching using SQL simple regular expression comparison.

Returns 1 (TRUE) or 0 (FALSE). If either expr or pat is NULL, the result is NULL.

With LIKE you can use the following two wildcard characters in the pattern:

CharacterDescription
%Matches any number of characters, even zero characters
_Matches exactly one character


mysql>
mysql> SELECT 'ABCDE!' LIKE 'ABCDE_';
+------------------------+
| 'ABCDE!' LIKE 'ABCDE_' |
+------------------------+
|                      1 |
+------------------------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT 'ABCDE!' LIKE '%A%C%';
+-----------------------+
| 'ABCDE!' LIKE '%A%C%' |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)








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.