Like clause in sql statement

Discussion in 'PHP' started by Cinta April, Apr 26, 2008.

  1. #1
    Hi I am trying to match a field that contains any alphabet but it does not return any rows?

    SELECT ..Name LIKE '%[a-z]%'

    why doesn't this return any rows?
     
    Cinta April, Apr 26, 2008 IP
  2. helpplease

    helpplease Banned

    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    your using regex in a like statement to you use regexp you need to "WHERE Name REGEXP '[REGEX-HERE]'"

    + check mysql manual for regexp

    liek should be WHERE Name LIKE '%henr%'
    returns henry, henroid, henrica etc
     
    helpplease, Apr 26, 2008 IP
  3. andrew1056

    andrew1056 Peon

    Messages:
    196
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think your regex should look like this (not sure... I'd have to test it myself. WHERE name LIKE '[A-Za-z]'; Google mysql LIKE statement. It'll tell you the correct way to match letters.
     
    andrew1056, Apr 26, 2008 IP
  4. Freewebspace

    Freewebspace Notable Member

    Messages:
    6,213
    Likes Received:
    370
    Best Answers:
    0
    Trophy Points:
    275
    #4
    Does anybody know where I can find mysql manual?
     
    Freewebspace, Apr 26, 2008 IP
  5. Cinta April

    Cinta April Banned

    Messages:
    262
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ok it turns out that like has no ability to match any alphabet in mysql. i guess i'll have to use regexp
     
    Cinta April, Apr 27, 2008 IP