-2

I have one MySQL query which is using LIKE for matching a string with one of my tables columns, and it's working fine in most of the scenarios.

select * from TableName where Column like "%STRING%"

But No I have one group of records that have "_0" in it. in this case, I get a get query something like this.

select * from TableName where Column like "%_0%"

in this case, MySQL is taking _ as a wildcard and skipping the first index from the string

Now my question is, is it possible to make this search work as it is, any way to tell MySQL it's not ( _ ) wildcard, So search for the string. I will really appreciate your help.

Thanks in advance.

Query Result Image

MA khan
  • 1
  • 1

1 Answers1

0

You can use a backslash to escape it:

where Column like '%\_0%'

Or use your own escape character:

where Column like '%$_0%' escape '$';
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Hi Gordon, Thanks for you response, i tried both of the methods you mention, but it didn't worked for me. its getting zero records althoug table has records which have _0 in it – MA khan Jul 29 '21 at 13:44