Bug #6648 LIKE bug
Submitted: 15 Nov 2004 22:46 Modified: 16 Nov 2004 14:59
Reporter: Donny Simonton Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S1 (Critical)
Version:4.1.7 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[15 Nov 2004 22:46] Donny Simonton
Description:
LIKE is not handling slashes (\) correctly.  See below for details.

mysql> SELECT * 
    -> FROM OvertureResults 
    -> WHERE term = '\\hong kong travel packages' ;
+----------------------------+-----+-------+-------+---------------------+
| term                       | any | clean | adult | updated             |
+----------------------------+-----+-------+-------+---------------------+
| \hong kong travel packages |   7 |     0 |     0 | 2004-10-20 16:32:12 |
+----------------------------+-----+-------+-------+---------------------+
1 row in set (0.00 sec)

mysql> SELECT * 
    -> FROM OvertureResults 
    -> WHERE term like '\\hong kong travel packages' ;
Empty set (0.00 sec)

mysql> SELECT *  FROM OvertureResults  WHERE term like '\hong kong travel packages';
Empty set (0.00 sec)

How to repeat:
See above.

Suggested fix:
Not sure.
[16 Nov 2004 14:59] MySQL Verification Team
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

Additional info:

From the MySQL manual

"Note: Because MySQL uses the C escape syntax in strings (for example, `\n' to represent newline), you must double any `\' that you use in your LIKE strings. For example, to search for `\n', specify it as `\\n'. To search for `\', specify it as `\\\\' (the backslashes are stripped once by the parser and another time when the pattern match is done, leaving a single backslash to be matched)."