Q:

Mysql, escaped string fields couldn't be searched with "LIKE" keyword

Consider one of the field( sample_field ) in Mysql table has as "your\'s data", when I query the same table as
SELECT * FROM sample_table WHERE sample_field = "your\'s data"
and also like as
SELECT * FROM sample_table WHERE sample_field = "your's data"
both of the above query returns 0 rows, even though the sample_field has the value as "your\'s data"
After a long search I came to know that, my search would be
SELECT * FROM sample_table WHERE sample_field = "your\\\'s data"
that is working very fine. but
SELECT * FROM sample_table WHERE sample_field LIKE "your\\\'s data"
is not working. So if I want to search any product or categories with quotes( like "your's data" ), in site search I must use LIKE keyword with wildcard patterns('%').  
Now I have found the answer that if I try like this
SELECT * FROM sample_table WHERE sample_field LIKE "your\\\\'s data"
as given in http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like, it is working fine. 
But please let me know why it needs this amount of 4 back slashes to achieve this ?
Thanks in advance

A:

You'll have to escape the escaping backslash, if you want it to be a literal backslash:
WHERE sample_field = "your\\'s data"

But really, having a backslash in your database in the first place is the mistake, fix that instead. 

