0% found this document useful (0 votes)
9 views5 pages

How To Do You Switch To The Imdb Database

Uploaded by

Shaik Ashraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

How To Do You Switch To The Imdb Database

Uploaded by

Shaik Ashraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. How to do you switch to the imdb database?

A. USE imdb;

2. How do you list all tables in the current database?


A. SHOW tables;

3. How to do you display the structure of the movies table?


A. DESCRIBE movies;

4. How do you select all columns from the movies table?


A. SELECT * FROM movies;

5. How do you select the name and year columns from the movies table?
A. SELECT name, year FROM movies;

6. How do you select the rank score and name columns from the movies
table?
A. SELECT rankscore, name
FROM movies;

Keyword:

LIMIT – Restricts the number of rows returned in the result set.

OFFSET – Specifies the number of rows to skip before starting to return


rows.

7. How do you get the first 20 rows of name and rankscore from movies?
A. SELECT name, rankscore
FROM movies
LIMIT 20;

8. Why use limit and offset?


A. LIMIT – efficient resource usage
OFFSET – Enables pagination
9. How do you get 20 rows of name and rankscore starting from the 41 st
row in movies?
A. SELECT name, rankscore
FROM movies
LIMIT 20
OFFSET 40;

Keyword:

ORDERBY – The ORDERBY clause in SQL is used to sort the result set by
one or more columns. By default, it sorts in ascending order (ASC),
but you can specify descending order (DESC) if needed.

10. How do you list the top 10 most recent movies by year, showing
name, rankscore and year?
A. SELECT name, rankscore, year
FROM movies
ORDER BY year DESC
LIMIT 10;

11. How do you list the top 10 oldest movies by year, showing name,
rankscore and year?
A. SELECT name, rankscore
FROM movies
ORDER BY year
LIMIT 10;

Keyword:

DISTINCT – The DISTINCT keyword in SQL is used to return only unique


(distinct) values.

It eliminates duplicate rows from the result set.

12. How do you list all unique genres from the movies_genres table?
A. SELECT DISTINCT genre
FROM movies_genres;
13. How do you list all unique combinations of first_name and
last_name from the directors table?
A. SELECT DISTINCT first_name, last_name
FROM directors;

Keyword:

WHERE – The WHERE clause in SQL is used to filter rows based on a specified
condition.

It enables you to extract only the rows that meet the specified criteria.

14. How do you list all movies with a rankscore greater than 9,
showing name, year and rankscore?
A. SELECT name, year, rankscore
FROM movies
WHERE rankscore > 9;

15. How do you list the top 20 movies with a rankscore greater
than9, sorted in descending order of rankscore?
A. SELECT name, year, rankscore
FROM movies
WHERE rankscore > 9
ORDER BY rankscore DESC
LIMIT 20;

16. How do you list all records from movies_genres where the genre
is comedy?
A. SELECT * FROM movies_genres
WHERE genre = ‘Comedy’;

17. How do you list all records from movies genres where the genre
is nor ‘Horror’?
A. SELECT *
FROM movies_genres
WHERE genre <> ‘Horror’; or WHERE genre NOT LIKE ‘Horror’;

18. What is the result of querying movies where rankscore equals


NULL?
A. SELECT name, year, rankscore
FROM movies
WHERE rankscore = NULL; or WHERE rankscore LIKE NULL;

19. How do you list the first 20 movies where the rankscore is NULL?
A. SELECT name, year, rankscore
FROM movies
WHERE rankscore IS NULL;

20. How do you list the first 20 movies where the rankscore is not
NULL?
A. SELECT name, year, rankscore
FROM movies
WHERE rankscore IS NOT NULL;

Keyword:

Logical operators:

In SQL, logical operators are used to combine multiple conditions in a WHERE


clause. These operators include AND, OR, NOT, BETWEEN, IN, LIKE, etc.

21. How do you list movies with a rankscore greater than 9 and
released after the year 2000?
A. SELECT name, year, rankscore
FROM movies
WHERE rankscore > 9 AND year > 2000;

22. How do you list the first 20 movies released after the year 2000?
A. SELECT name, year, rankscore
FROM movies
WHERE NOT year <=2000 LIMIT 20;

23. How do you list movies with a rankscore greater than 9 or


released after the year 2007?
A. SELECT name, year, rankscore
FROM movies
WHERE rankscore >9 OR year>2007;

24. How do you list movies released between 1999 and 2000,
inclusive?
A. SELECT name, year, rankscore
FROM movies
WHERE year BETWEEN 1999 AND 2000;

You might also like