Is Null across multiple fields?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • artemetis
    New Member
    • Jul 2007
    • 76

    #1

    Is Null across multiple fields?

    Hey there...
    I've a simple db and need to run a query to check for is null on multiple fields.

    Basically I need to include in my report the record if any of these fields are "is null" age, gender, eye, hair


    This code only returns value if all criteria are null. I need to check any field for null.

    Code:
    SELECT tblMain.uid, tblMain.age, tblMain.gender, tblMain.hair, tblMain.eye
    FROM tblMain
    WHERE (((tblMain.age) Is Null) AND ((tblMain.gender) Is Null) AND ((tblMain.hair) Is Null) AND ((tblMain.eye) Is Null));
  • beacon
    Contributor
    • Aug 2007
    • 579

    #2
    Hi artemetis,

    Try changing the AND in your WHERE clause to OR. By using AND, your query is looking for the conditions of ALL to be met. If you use OR, the query will only look for ONE OR MORE conditions to be met.

    Comment

    • artemetis
      New Member
      • Jul 2007
      • 76

      #3
      Geez...I tried that and at first it didn't work...now it is working. Oh well.

      Thanks for the support!

      Comment

      • beacon
        Contributor
        • Aug 2007
        • 579

        #4
        Happy to help...

        Comment

        Working...