0

I have a table where a column allows special characters like / , \ , @ , $ .

Now when I am trying to search such records from table, I am unable to get. I have tried one query but it is returning 0 rows but actually there is 1 record existing. How to write a query in this case ?

My query (which is giving the wrong result) was something like this

select * from mytable where column7 like '%jk\xyz@%' 
Nickz2
  • 93
  • 2
  • 3
  • 14

1 Answers1

1

You may need to escape some special characters - particularly backslash. Note that with the LIKE operator - there is a two part process to issuing the command & both strip escaping - so to search for a single backslash you need to use 4 backslashes.

select * from mytable where column7 like '%jk\\\\xyz@%' 

See this : MySQL LIKE operator with wildcard and backslash and http://dev.mysql.com/doc/refman/5.6/en/string-comparison-functions.html#operator_like

Community
  • 1
  • 1
PaulF
  • 6,673
  • 2
  • 18
  • 29