Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases SQL Basics Finding the Data You Want Filtering Out or Finding Missing Information

How do I query to find all of the rows with missing data without individually typing out each column name?

Example: SELECT * FROM movies WHERE (any row) IS NULL

1 Answer

Anna Pichugina
Anna Pichugina
25,364 Points

I googled around a bit and couldn't find an easy fix for selecting all rows which have null values in any column. Here's the gist of most answers: https://stackoverflow.com/questions/9705369/is-there-a-quick-way-to-check-if-any-column-is-null

If you have a lot of columns and want to speed things up a bit you could select your column names for the table, copy paste them into an IDE and use its multi-cursor shortcuts to insert the repeating 'IS NULL OR ' using something like:

SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'some_table';