Podcast
Questions and Answers
Use the ______________ statement to get all the columns from a table.
Use the ______________ statement to get all the columns from a table.
SELECT *
The __________________ clause is used to group rows that have the same values in one or more columns.
The __________________ clause is used to group rows that have the same values in one or more columns.
GROUP BY
The __________________ operator is used to select a range of values.
The __________________ operator is used to select a range of values.
BETWEEN
The __________________ clause is used to filter records and fetch only those that meet certain conditions.
The __________________ clause is used to filter records and fetch only those that meet certain conditions.
The __________________ function is used to count the number of rows in a table.
The __________________ function is used to count the number of rows in a table.
Use the __________________ clause to get rows where values in a group meet a criterion.
Use the __________________ clause to get rows where values in a group meet a criterion.
The __________________ operator is used to select rows where a column is one of several values.
The __________________ operator is used to select rows where a column is one of several values.
Use the __________________ wildcard to select rows where a column contains specific letters.
Use the __________________ wildcard to select rows where a column contains specific letters.
The __________________ clause is used to get summaries grouped by values in a specific order.
The __________________ clause is used to get summaries grouped by values in a specific order.
Use the __________________ statement to get a column from a table by name.
Use the __________________ statement to get a column from a table by name.
Flashcards are hidden until you start studying
Study Notes
Filtering Data
- Filter on numeric columns using
WHERE
clause with operators:>
,>=
,<
,<=
,!=
- Example:
SELECT franchise, inception_year FROM franchises WHERE inception_year > 1928
Aggregating Data
- Use aggregate functions:
COUNT(*)
,SUM(col)
,AVG(col)
,MIN(col)
,MAX(col)
- Example:
SELECT COUNT(*) FROM franchises
- Group data using
GROUP BY
clause - Example:
SELECT owner, COUNT(*) FROM franchises GROUP BY owner
Querying Tables
- Retrieve all columns using
SELECT *
- Retrieve specific columns using
SELECT col1, col2
- Use
FROM
clause to specify table name - Example:
SELECT franchise, inception_year FROM franchises
Filtering on Text Columns
- Filter on text columns using
WHERE
clause with operators:=
,IN
,LIKE
- Example:
SELECT franchise, original_medium FROM franchises WHERE original_medium = 'book'
- Use
LIKE
operator with wildcard%
to match patterns - Example:
SELECT franchise, original_medium FROM franchises WHERE original_medium LIKE '%oo%'
Grouping and Filtering
- Use
HAVING
clause to filter groups - Example:
SELECT original_medium, SUM(n_movies) AS total_movies FROM franchises GROUP BY original_medium HAVING total_movies > 10
- Use
WHERE
clause to filter before grouping - Example:
SELECT original_medium, SUM(n_movies) AS total_movies FROM franchises WHERE original_medium IN ('movie', 'video game') GROUP BY original_medium
MySQL-Specific Syntax
- Not all code works in every dialect of SQL.
- MySQL has its own syntax and features.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.