Retrieving string with \(backslash) from mysql table

Discussion in 'MySQL' started by computerzworld, Apr 29, 2009.

  1. #1
    Hello,
    I am having table in which one field is having value with \ (backslash). When I search that string it doesn't return result.


    Here is my query.

    select * from table where field like ''%A\Value%' . Even if the result is there in the database . Is there any way to retrieve the value for the value containing \ in it. Please help me. Thanks in advance.
     
    computerzworld, Apr 29, 2009 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Use double slashed e.g.

    select * from table where field like ''%A\\Value%'
     
    mwasif, Apr 29, 2009 IP
  3. computerzworld

    computerzworld Active Member

    Messages:
    214
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    It worked by using 4 \s instead of two...
    
    select * from table where field like ''%A\\\\Value%'
    
    Code (markup):
     
    computerzworld, Apr 30, 2009 IP
  4. sunnyverma1984

    sunnyverma1984 Well-Known Member

    Messages:
    342
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #4
    try this
    select * from table where field like '%\\%'
    Code (markup):
     
    sunnyverma1984, May 1, 2009 IP