0

I have a list of strings. They are all absolute paths (no relative at the moment) and they all start with \ (windows folder separator)

When I do a query with a like using

select * from list where name like @foo

and foo is

@"\a" + %

I get no results. If I use %\a% I get results. I then tried using mysql command line and wrote

where name like '\a%' limit 10;

I get no results there as well unless i write %\a%. Why doesn't it like \? and how do i have a string start with \a? I don't want to get \random\apples\file when I am expecting \apples\file

BenMorel
37k52 gold badges208 silver badges339 bronze badges
asked Nov 28, 2012 at 20:41
3
  • 1
    It sounds like an escaping issue. Have you tried doubling the backslash, i.e. @"\\a" + %? Commented Nov 28, 2012 at 20:43
  • 3
    You should know that the backslash is used for escaping... Commented Nov 28, 2012 at 20:43
  • @rekire: Shouldnt the fact that i'm putting the value through a parameter escape the value for me? Commented Nov 28, 2012 at 20:54

2 Answers 2

8

Because \ is the escaping character .

Try replacing it with \\ instead

Special Character Escape Sequences

answered Nov 28, 2012 at 20:43
Sign up to request clarification or add additional context in comments.

2 Comments

seriously what the hell!? Very relevant. stackoverflow.com/questions/13614291/…
1

try this

\ is a sign which escapes the next sign.. sometimes used to escape a \" quote or the backslash itself

where name like '\\a%' limit 10;

answered Nov 28, 2012 at 20:45

1 Comment

oops i forgot that its \ in the cli however wtf i thought parameter values would escape this

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.