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 field is empty?

Discussion in 'MySQL' started by Weirfire, Sep 19, 2005.

  1. #1
    Is it possible to run a query to return all results where a certain field is not empty?
     
    Weirfire, Sep 19, 2005 IP
  2. JoeO

    JoeO Peon

    Messages:
    431
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #2
    sure !=NULL or !="" ... depending on how its empty
     
    JoeO, Sep 19, 2005 IP
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    I just read on another forum this solution

    SELECT * FROM table_name WHERE column_name > '';

    for those who come across this thread in the future.


    Thanks JoeO :)
     
    Weirfire, Sep 19, 2005 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    ISNULL([columnname]) is a good operator in MySQL as well.
     
    digitalpoint, Sep 19, 2005 IP
  5. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #5
    So to use that for my problem could you put

    SELECT * FROM table_name WHERE !(ISNULL([columnname]));
     
    Weirfire, Sep 19, 2005 IP
  6. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #6
    Probably just easier to do this:

    SELECT * FROM table_name WHERE NOT ISNULL([columnname]);
    Code (sql):
     
    digitalpoint, Sep 19, 2005 IP
  7. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Cheers Shawn :)
     
    Weirfire, Sep 19, 2005 IP
  8. kineticdc

    kineticdc Peon

    Messages:
    347
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks Shawn for the answer
     
    kineticdc, Sep 1, 2008 IP