Patty_Tu Posted October 18, 2021 Share Posted October 18, 2021 I'm working on this session, and it shows if I'd like to test NULL value, I'll need to use below syntax: However, I'd like to know what if I have no idea which column(s) has(have) NULL value? How should I make a query to look for ANY record that includes NULL value without writing specific column_name? Link to comment Share on other sites More sharing options...
Ingolme Posted October 18, 2021 Share Posted October 18, 2021 The only way is to do a null test on every column in the table. SELECT * FROM table_name WHERE column1 IS NULL OR column2 IS NULL OR column3 IS NULL OR column4 IS NULL I can't think of any practical use case where I'd want to test for null in all columns. Link to comment Share on other sites More sharing options...
Patty_Tu Posted October 18, 2021 Author Share Posted October 18, 2021 But what if there are lots of columns in that table? I just think it's inefficient to mention every column under WHERE syntax lol... Isn't there any other way to test if any row has NULL value? Link to comment Share on other sites More sharing options...
Ingolme Posted October 18, 2021 Share Posted October 18, 2021 Unfortunately, there is no way to do that in standard SQL, but it really won't take longer than 5 minutes to write the query even if the table has 100 columns. Link to comment Share on other sites More sharing options...
Patty_Tu Posted October 19, 2021 Author Share Posted October 19, 2021 7 hours ago, Ingolme said: y won't take longer than 5 minutes to write the query even if the table has 100 Ok! Thanks for your help!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now