First you execute the string syntax, then for the LIKE syntax.
In LIKE the % and _ characters have a special meaning, so if you want to find the literal % , you need to use \% , and if you want to find the literal \% you need to avoid the backslash, as in \\% .
In the string syntax, " obviously has a special meaning, so if you want to include a quote in a string, you need to escape it as \" and include the literal \" in the string, you need to avoid the backslash as in \\" .
So, in both syntaxes you need to exit \ .
If you do not want to use \ to avoid the LIKE pattern, you can use the ESCAPE keyword. For instance:
... where test LIKE "a\\b%" ESCAPE '|';
So you need to write |% , |_ or || to avoid these special characters.
source share