SQL Flashcards

1
Q

What would the following command do?

SELECT * FROM movies

A

It would return all results from the table “movies”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does WHERE do?

A

It filters queries based on criteria.

Example:
SELECT * FROM movies
WHERE imdb_rating > 8;

This would return every column from the table “movies” for any rows with a value greater than 8 in the “imdb_rating” column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does AS do?

A

It determines what will be displayed as the column name for a query. It does not change the actual column name in the database.

Example:
SELECT imdb_rating AS ‘IMDB Rating’
FROM movies;

This would return the column “imdb_rating” but would display a title of “IMDB Rating”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What command could you use to return the rows from the table “movies” where the “name” column is either “Se7en” or “Seven”?

A

SELECT *
FROM movies
WHERE name
LIKE ‘Se_en’;

The character “_” is wild.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the % operator do?

A

It filters query results to return any results which include the characters preceding, following, or between the percent symbol(s).

Example:
SELECT *
FROM movies
WHERE name
LIKE ____

Replacing the underlined values with
‘man%’ would return movies starting the string “man”

‘%man’ would return movies ending with the string ‘man’

‘%man%’ would return movies which contain the string ‘man’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly