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 trialSean Flanagan
33,235 PointsRetrieving 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
Troy Huffman
2,799 PointsHey 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
Nathan Tallack
22,160 PointsComma must be between your columns.
Sean Flanagan
33,235 PointsAre you meant to comma-separate the columns after SELECT or after WHERE, or both?
Nathan Tallack
22,160 PointsWhen 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
33,235 PointsHi 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.
Sean Flanagan
33,235 PointsSean Flanagan
33,235 PointsIt helps. Thanks Troy! Sean :-)