The default equivalent character is \ . So just the % s \ prefix like: \% :
the manual clearly says:
To check literary instances the nature of the wild card, the preceding escape character. If you do not specify the ESCAPE character, "\" is assumed.
Find % in Stack%Overflow :
mysql> select 'Stack%Overflow' like '%\%%'; +------------------------------+ | 'Stack%Overflow' like '%\%%' | +------------------------------+ | 1 | <----- Found +------------------------------+ 1 row in set (0.00 sec)
Find % in StackOverflow :
mysql> select 'StackOverflow' like '%\%%'; +-----------------------------+ | 'StackOverflow' like '%\%%' | +-----------------------------+ | 0 | <----- Not Found +-----------------------------+ 1 row in set (0.00 sec)
EDIT:
If you call this request with PHP, you will need to use \\ . This is because even PHP uses \ as an escape character. Therefore, for MySQL to get \ , you need to have \\ in PHP.
codaddict
source share