Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases SQL Basics Finding the Data You Want Review & Practice with SQL Playgrounds

Tyler McDonald
.a{fill-rule:evenodd;}techdegree seal-36
Tyler McDonald
Full Stack JavaScript Techdegree Graduate 16,676 Points

More efficient way to solve "Movies with Any Missing Data"?

The solution for the Movies with Any missing data question would become extremely long if there were many columns:

-- Find all movies with any missing data

SELECT * FROM movies 
OR title IS NULL
OR year_released IS NULL
OR genre IS NULL;

Is there a better way to solve this instead of listing each column?

1 Answer

Steven Parker
Steven Parker
217,570 Points

Since a primary key cannot be NULL, you can simplify this a bit by not testing the ID column.

Otherwise, if the database has a programming extension you could use that to write a function that uses table metadata to identify and test the columns, but that's not standard SQL (and way beyond the scope of this course).