November 25, 2017 at 7:40 am
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 1 | Column 2 | Column 3 | |
| Record 1 | A | 1 | 3 |
| Record 2 | B | 4 | NULL |
| Record 3 | NULL | 2 | 5 |
Here, I would only want Records 2 and 3 returned. Record 1 would not as there are no NULLs across the columns.
Cheers,
Matty
November 25, 2017 at 8:18 am
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
November 26, 2017 at 4:28 am
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 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply