Show only records where a NULL exists across columns...

  • Hi Team,

    I'm struggling with the syntax of a WHERE statement to return only the records where a NULL exist within any column in my table.

    Example below:

     Column 1Column 2Column 3
    Record 1A13
    Record 2B4NULL
    Record 3NULL25

    Here, I would only want Records 2 and 3 returned.  Record 1 would not as there are no NULLs across the columns.

    Cheers,

    Matty

  • You're going to need to inspect each column and check if it has a value of NULL. This isn't going to be quick, but:
    SELECT *
    FROM YourTable
    WHERE Column1 IS NULL
       OR Column2 IS NULL
       OR Column3 IS NULL
       OR ... IS NULL;

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thanks for responding, Thom.

    I was already using the same syntax, but getting unexpected results.  Once I split my queries up, things worked.

    Cheers,

    Matty

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply