1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

mysql - select where equals a number

Discussion in 'PHP' started by Silver89, Feb 16, 2009.

  1. #1
    **Solved**

    SELECT * FROM table WHERE cat REGEXP "[0-9]+"

    **

    How can I perform a mysql_query that selects items from a row that are just in number format?

    I was thinking of suing regular expression or like, but am not sure how?

    Thanks
     
    Silver89, Feb 16, 2009 IP
    SedNaX likes this.
  2. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #2
    I don't exactly know what you mean.. Could you please explain a bit more thorough what you want? What do you mean with just in number format?
     
    SedNaX, Feb 16, 2009 IP
    Silver89 likes this.
  3. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Return all the rows with mysql
    Then loop round them and do is_number [or numeric i forget which] in php to check
     
    m0nkeymafia, Feb 16, 2009 IP
    Silver89 likes this.
  4. kuzmanin

    kuzmanin Peon

    Messages:
    242
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    kuzmanin, Feb 16, 2009 IP
    Silver89 likes this.
  5. CarPriceDatabase

    CarPriceDatabase Guest

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    maybe use (int) before your return value
     
    CarPriceDatabase, Feb 16, 2009 IP
    Silver89 likes this.
  6. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #6
    Thanks guys got it working with the following for future reference:

    SELECT * FROM table WHERE cat REGEXP "[0-9]+"

    This selects results that are just numbers! :)
     
    Silver89, Feb 16, 2009 IP