Bug #2962 SELECT doesn't work if varchar begins with \\
Submitted: 25 Feb 2004 15:10 Modified: 25 Feb 2004 15:23
Reporter: Nathan Jensen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1 OS:Windows (windows 2000)
Assigned to: Dean Ellis CPU Architecture:Any

[25 Feb 2004 15:10] Nathan Jensen
Description:
SELECT does not query correctly if a varchar begins with "\\". For example, suppose you have a varchar field in a record that stores the following string:

\\MyServer\MyShare

. . .and you want to retrieve this record with a wildcard like so:

SELECT *
FROM MyTable
WHERE MyField LIKE '\\\\MyServer\\%'

This query should return at least one record, but it returns no records at all.

How to repeat:
see Description.

Suggested fix:
obvious what needs to be done.
[25 Feb 2004 15:23] Dean Ellis
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:

Please read http://www.mysql.com/doc/en/String_comparison_functions.html for LIKE:

"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)."
[25 Feb 2004 15:48] Nathan Jensen
thank you for the info, and i'm sorry i reported this as a bug. i didn't realize that each backslash had to be replaced with 4 backslashes when doing wildcard searches.