SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    UK
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    detecting empty table cell

    Hi i want to select all cells that have omega and the img path is not empty. I can list the products from the omega range but its still showing the one with no images.. i.e. don't have a path to the image. am i going about this the right way?

    Please point me in the right direction.

    Code:
    SELECT *
    FROM `worktops`
    WHERE `range` = 'omega'
    AND `imgpath` IS NOT NULL

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you have inserted an empty string (i.e. ' ' or '') into the cell then that cell would still be returned by an IS NOT NULL search. Is that the case for you?

    NULL and empty string are two separate concepts that people mix up a lot.

  3. #3
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ^^^^ + 1. More specifically, try this:
    Code:
    SELECT *
    FROM `worktops`
    WHERE `range` = 'omega'
    AND (`imgpath` IS NOT NULL AND TRIM(`imgpath`) != '')

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,327
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by transio View Post
    AND (`imgpath` IS NOT NULL AND TRIM(`imgpath`) != '')
    simpler even more --
    Code:
    AND imgpath > ''
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •