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 Review & Practice with SQL Playgrounds

Sean Flanagan
Sean Flanagan
33,235 Points

Retrieving missing data from multiple columns

Hi guys and girls.

I noticed that you can retrieve missing data from one column only. Where the SQL playground says to find any movies with missing data, I typed:

SELECT * FROM movies WHERE year_released IS NULL AND genre IS NULL;

but this didn't work.

I couldn't find anything on the cheat sheet either.

3 Answers

Hey Sean,

What about:

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

The thing that messed your original query up was the AND - you are basically saying to return all results where the year_released column AND the genre column and empty. Nothing in the table matches that requirement.

Hope that helps! Troy

Sean Flanagan
Sean Flanagan
33,235 Points

It helps. Thanks Troy! Sean :-)

Nathan Tallack
Nathan Tallack
22,159 Points

Comma must be between your columns.

Sean Flanagan
Sean Flanagan
33,235 Points

Are you meant to comma-separate the columns after SELECT or after WHERE, or both?

Nathan Tallack
Nathan Tallack
22,159 Points

When you are saying SELECT * that means select all columns.

Try replacing * with a column name. Remember, they are case sensitive. If you want to return more than one column name then separate them with spaces. :)

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Nathan. Thanks for your help.

I tried:

SELECT year_released genre FROM movies WHERE year_released IS NULL AND genre IS NULL;

and got no results.