xpda xpda - 3 months ago 8
MySQL Question

Why doesn't "Like" match a query when equal does?

In the following query, a match is found:

SELECT * FROM images WHERE originalpath =
"d:\\pic16\\160623 bugs\\RW2-jpg\\P1280627.jpg";


However, a match is not found using "Like":

SELECT * FROM images WHERE originalpath Like
"d:\\pic16\\160623 bugs\\RW2-jpg\\P1280627.jpg";


I get the same result using "\" before the " ", ":", "-", and ".":

SELECT * FROM images WHERE originalpath Like
"d\:\\pic16\\160623\ bugs\\RW2\-jpg\\P1280627\.jpg";


How can I make the match using
Like
? (Mysql 5.6, Innodb)

Answer

I think the reason is because you need to slash every slash when writing an expression try something like this SELECT * FROM images WHERE originalpath Like "d:\\\\pic16\\\\160623 bugs\\\\RW2-jpg\\\\P1280627.jpg"; While writing an expression then because certain characters can have a different meaning they need to be escaped in order to show that they are literal.

Comments