Find empty fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    Find empty fields

    How can empty fields be detected.
    Code:
    SELECT * FROM products WHERE 
    description IS EMPTY
    The field may be NULL
    or just empty and I suppose even space characters.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    [code=sql]
    SELECT *
    FROM products
    WHERE description IS null OR rtrim(descripti on)=''
    [/code]

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      Thanks Delerna
      I figured as much, I do something similar in MySql.
      Although I once had a regex that achieved this.

      But it may need to be RTRIM(LTRIM(des cription))=''

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        also...

        Code:
        WHERE isnull(rtrim(ltrim(description)),'') = ''

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          Code:
          WHERE isnull(rtrim(ltrim(description)),'') = ''
          I like that ck9663, although I can't quite see how it works.
          It looks like a COALESCE should be there

          Comment

          • code green
            Recognized Expert Top Contributor
            • Mar 2007
            • 1726

            #6
            Got it. isnull() function rather than IS NULL

            Comment

            Working...