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

Not able to figure out the answer

What we will do to get the results of this SQL Playground

I have a doubt in - Movies with Any Missing Data

3 Answers

Salvador Gutierrez
Salvador Gutierrez
3,801 Points

The query must be completed with the function is null.

  • -- Find all reviews in the review table with the rating of 5

select * from reviews where rating=5;

  • -- Find all the actors with the last name of Cruise

select * from actors where name like ("%Cruise%");

  • -- Find all movies in the database from the 1980s

select * from movies where year_released between 1980 and 1990;

  • -- Find all movies where the release year is missing

select * from movies where year_released is null;

  • -- Find all movies where the genre column has information present

select * from movies where genre!='';

  • -- Who are the actors with the ids of 12127, 6901, 2071 and 2831?

select * from actors where id=12127 or id=6901 or id=2071 or id=2831;

  • --- Which users gave reviews of 3 or lower?

select * from reviews where rating<=3;

  • -- Review ratings should be only be 1-5. Find all the invalid ratings in one query

select * from reviews where rating<0;

  • -- Find all movies with any missing data

select * from movies where year_released is null or genre is null;

  • -- Find all movies where the title begins with Alien

select * from movies where rtrim(title,5) like ('%Alien%');

  • -- Find all reviews by the user love

select * from reviews where username='__love__';

  • -- Find all actors whos first name starts with Will

select * from actors where substr(name,0,5) like ('%Will%');

Michael Pashkov
Michael Pashkov
22,024 Points

-- Review ratings should be only be 1-5. Find all the invalid ratings in one query

SELECT * FROM reviews WHERE rating BETWEEN 1 AND 5 OR rating < 0;

I used a between statement between 1980 and 1989 that selects all movies from movies where the year_released is between 1980 and 89'. Hope this helps:

SELECT * FROM movies WHERE year_released BETWEEN "1980" AND "1989";