Working with Clauses

Consider the tables books and review given below.

CREATE TABLE books( 
 book_id int, 
 book_title varchar(30), 
 year_published int, 
 book_lang varchar(30), 
 PRIMARY KEY(book_id) 
 ); 
 
CREATE TABLE review( 
 book_id int, 
 rev_id int, 
 stars float, 
 reviewcount int, 
 FOREIGN KEY(rev_id) REFERENCES bookreviewer(rev_id), 
 FOREIGN KEY(book_id) REFERENCES books(book_id) 
 );

Write a query to find all the years in which a published book received a 3 or 4 rating.

Options
1.SELECT DISTINCT year_published
FROM books, review
WHERE books.book_id = review.book_id 
AND stars IN (3, 4)
ORDER BY year_published;
2.SELECT DISTINCT year_published 
FROM books 
INNER JOIN review 
ON books.book_id = review.book_id 
WHERE stars IN (3, 4) 
ORDER BY year_published;

3.Both Choice 1 and 2

4.Neither Choice 1 nor 2
Previous PostNext Post

Related Posts