Escaping wildcard values
If the string you are searching for with your wildcard expression has a wildcard in it, you will need to escape it for the wildcard expression to work as expected. Escaping means to allow a special character in a filter string. For example, if the string you want to filter on has a percent sign or an underscore in the string, you will need to escape these characters so that the SQL query doesn't fail or doesn't work as expected.
Let's say your field contains an underscore and you want to filter on those values that have an underscore; you need to escape the underscore to find these values. You can't just use WHERE fieldname LIKE '%_%' in your query because MySQL would think you were filtering on a set of characters ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access