EXISTSoperator checks whether a subquery is empty or not, instead of checking whether values are in the subquery.
R1. Then we're creating a new relation called
R2. For each movie we're going to check if there is another
mID, where the
R2is the same as the
R1. We then say that each
mIDshould be different, and not equal to itself.
Yearwould be the largest.
Yearis greater than the first movie. This would be a form of query that we could write whenever looking for the greatest value of some-sort.
ALLkeyword tells us that instead of checking whether a value is in or not in the result of a subquery, we're going to check if the value has a certain relationship with
ALLthe results of a subquery.
Ratingof a movie is greater than or equal to
ALLelements of the subquery which returns all the
Ratingsof each movie.
Ratingof 5, since there is no single movie with a greater
Ratingthan every other movie.
ANYkeyword performs very similar to the
ALLkeyword, except instead of having to satisfy a condition with
ALLof the elements of a set, it only has to satisfy a condition with at least one element of a set.
Yearthat is not the smallest
Yearvalue. In other words, we are looking for movies whose
Yearis greater than
Yearis less than this movie. We then get a resulting table with all the movies that do not have the least
Yearvalue. Thus, we would get every movie except for The Godfather, because it has the smallest
ALLoperators are very convienient when creating queries, however, they are not vital to creating a query. We can always write a query that would normally use the
ALLkeywords, by using the