a little help with a mysql query, please.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mr. Mike
    Confirmed User
    • Aug 2004
    • 913

    #1

    a little help with a mysql query, please.

    Is it possible to count the total number of fields in a table that are empty? If so, please let me know, I cant find anything in the manual.
    Sig for sale. ICQ: 163-545-054
  • Kaylum
    Confirmed User
    • Aug 2005
    • 465

    #2
    yes.

    select count(*) from table_name where field1 isNULL and field2 isNULL and ...;

    or if the fields are empty as in (they were set empty by code):

    select count(*) from table_name where field1 = '' and field2 = '' and ...;

    i don't know of any built-in mysql function that will help, due to the fact of varying structure of tables.

    peace
    -- "You can't stop ingenuity, trust me.."

    Comment

    • Kaylum
      Confirmed User
      • Aug 2005
      • 465

      #3
      ooops, nevermind.

      that just returns the number of records with "empty" fields.. not what you wanted.
      -- "You can't stop ingenuity, trust me.."

      Comment

      • Mr. Mike
        Confirmed User
        • Aug 2004
        • 913

        #4
        Originally posted by Kaylum
        yes.

        select count(*) from table_name where field1 isNULL and field2 isNULL and ...;

        or if the fields are empty as in (they were set empty by code):

        select count(*) from table_name where field1 = '' and field2 = '' and ...;

        i don't know of any built-in mysql function that will help, due to the fact of varying structure of tables.

        peace
        Excellent! Thanks a million!
        Sig for sale. ICQ: 163-545-054

        Comment

        • Mr. Mike
          Confirmed User
          • Aug 2004
          • 913

          #5
          ah, yeah I just noticed that now. It actually is what I need, but this couints tyhe entire database, enstead of a specific column. I need the blank fields in USERS where id=x
          Sig for sale. ICQ: 163-545-054

          Comment

          Working...