Select records that begin with a number

Discussion in 'Programming' started by papa_face, Sep 19, 2007.

  1. #1
    Hello,
    In mysql how do i select records that begin with a number?

    Thanks :)
     
    papa_face, Sep 19, 2007 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    SELECT * FROM tableName WHERE fieldName REGEXP '^[:digit:]';
    Code (markup):
     
    phper, Sep 19, 2007 IP
  3. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #3
    Nope that still finds any record containing a number. I just want it to be the first character.
     
    papa_face, Sep 20, 2007 IP
  4. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #4
    Got it:
    SELECT * FROM tableName WHERE fieldName REGEXP '^[0-9]';
    Code (markup):
    I think that will get the first character as a number?
     
    papa_face, Sep 20, 2007 IP