I’m running a query on a table that contains values, some of the form “jsFunc(‘H:\\directory\\subdir\\whatever.ext’)”, others of the form “jsFunc(‘\\\\ServerName\\directory\\subdir\\whatever.ext’)” along many other random strings items.
I want to select anything with the form “H:\\directory\\subdir”
heres my query…
SET @s = 'H:\\\\directory';
SELECT * FROM 'db'.'table' WHERE column LIKE CONCAT('%',@s,'%')
which produces no results. I’ve tried this without the variable/concat.
some values that produce results, and some that do not(but I feel they should)
@s = 'H:'; /* returned rows*/
@s = 'H:\\'; /*no returned rows*/
@s = 'H:\\\\'; /* returned rows*/
@s = 'H:\\\\directory'; /*no returned rows*/
@s = '\\\\directory'; /* returned rows*/
@s = '\\\\directory\\\\subdir'; /*no returned rows*/
/* and worse of all... */
@s = 'H:\\\\directory\\\\subdir'; /*no returned rows. these are the rows I want*/
At first I thought the order of escaping operations might be causing the problem, hence the concatted ‘%’ to make sure they were not being escaped, but there doesn’t seem to be a difference. Is there some sort of escape voodoo going on here that I am missing?
u should just do
@s = 'H:\\'; select @s;then u would realized u need to double + double escape in order to achieve the like search
string H:\\ => H:\\\\\\\\