Skip to content

Course Retriever is reader-supported. When you buy through links on our site, we may earn a commission.

Codecademy SQL Cheat Sheet

To help you master SQL, we put together a reference guide based on cheat sheets from Codecademy and other online coding platforms. You now have a handy resource to use the next time you are writing SQL queries!

Share
Codecademy SQL Cheat Sheet

Overview of the SQL Cheat Sheets from Codecademy, Dataquest, and Udacity

SQL may not be the most exciting thing in the world. But you need to know it if you work with databases!

SQL — which stands for Structured Query Language — is the language used to query data from the majority of relational databases, including MySQL, SQLite, PostgreSQL, and Apache Hive. You can use SQL for things like filtering and extracting data from a database.

Several online learning providers — Codecademy, Dataquest, and Udacity — have great courses to help you start learning SQL. They have also written some of the best SQL cheat sheets you will find anywhere online. 

Whether you are learning SQL through an online course or by some other means, we think it can be really helpful to have everything in one place. That is why we developed a quick reference guide to point you to the best SQL cheat sheet for your needs. 

Let’s get started!

Codecademy’s SQL Cheat Sheets

Codecademy has written several SQL cheat sheets covering various topics. We summarized them for you here. If you want to know the details, just click on the links below.

Codecademy’s SQL Cheat Sheet for Data Acquisition

This SQL cheat sheet from Codecademy covers almost every topic related to data acquisition. Codecademy also has separate cheat sheets for data manipulation and queries, which cover the same topics.

_ Wildcard: This character matches any single unspecified character.

% Wildcard: This character matches zero or unspecified characters.

ALTER TABLE: This statement modifies the columns of an existing table. You can also use it to add a new column.

AND: This operator allows multiple conditions to be combined.

AS: This clause can serve as an alias for columns of tables.

BETWEEN: This operator can filter by a range of values.

CREATE TABLE: This statement creates a new table in a database.

DELETE: This statement deletes records in a table.

DISTINCT: This clause can select unique values of a column.

INSERT INTO: This statement adds a new record to a table.

LIKE: This operator can help match a specified pattern.

LIMIT: This clause can narrow a result to a specific number of rows.

NULL: This value refers to a column having no values.

OR: This operator allows multiple conditions to be combined.

ORDER BY: This clause can sort by a specific column either alphabetically or numerically.

SELECT: This statement returns all columns from a table.

UPDATE: This statement modifies records in a table.

WHERE: This clause filters records that match a certain condition.

In addition, this SQL cheat sheet from Codecademy covers column constraints — the rules applied to the values of individual columns.

PRIMARY KEY: This rule uniquely identifies a row.

UNIQUE: This rule ensures that columns have a different value for every row.

NOT NULL: This rule ensures that columns have a value.

DEFAULT: This rule sets a default value when no value is specified.

Codecademy’s SQL Cheat Sheet for Aggregate Functions

This SQL cheat sheet from Codecademy covers topics related to aggregate functions.

AVG(): This function returns the average value in a column.

COUNT(): This function returns the total number of rows that match the specified criteria.

MAX(): This function takes the name of a column as an argument and returns the largest value in a column.

MIN(): This function returns the smallest value in a column.

ROUND(): This function rounds a number value to a specified number of places.

SUM(): This function takes the name of a column as an argument and returns the sum of all the values in that column.

GROUP BY: This clause groups records by identical values in one or more columns. It’s often used in combination with aggregate functions to query information of similar records.

HAVING: This clause further filters the result set groups provided by the GROUP BY clause. 

Codecademy’s SQL Cheat Sheet for Multiple Tables

This SQL cheat sheet from Codecademy covers topics related to working with multiple tables.

CROSS JOIN: This clause combines each row from one table with each row from another. This JOIN is helpful for creating all possible combinations for the records in two tables.

INNER JOIN: This clause is the default JOIN and only returns results matching the condition specified by ON.

JOIN: This clause allows for the return of results from more than one table by joining them together with other results based on common column values specified using an ON clause.

LEFT JOIN: This clause returns every row in the left table and, if the join condition is not met, then NULL values are used to fill in the columns from the right table.

OUTER JOIN: This clause combines rows from different tables even if the join condition is not met.

UNION: This clause combines results that appear from multiple SELECT statements and filters duplicates.

WITH: This clause stores the result of a query in a temporary table using an alias.

In addition, this SQL cheat sheet from Codecademy covers foreign and primary keys.

A foreign key is a reference in one table’s records to the primary key of another table. The foreign key plays a vital role in maintaining multiple records for a specific row.

A primary key column in a SQL table is used to uniquely identify each record in that table. A primary key cannot be NULL, and the same value cannot re-occur in a primary key column. Primary keys are often used in JOIN operations.

Dataquest’s SQL Cheat Sheet

Dataquest’s cheat sheet covers the following fundamental and intermediate SQL statements:

DROP VIEW: This statement drops a view of the table.

EXCEPT: This statement selects rows that occur in the first

SELECT statement but not the second SELECT statement.

FROM: This statement selects specific columns from a table.

INTERSECT: This statement selects rows that occur in two SELECT statements.

LIMIT: This statement selects specific rows on a table.

ORDER BY: This statement sorts a column.

SELECT: This statement can perform single and multiple calculations.

UNION: This statement selects rows that occur in one or more SELECT statements.

VIEW: This statement creates a view of the table.

In addition, Dataquest’s cheat sheet discusses the following concepts:

Comments: There is a discussion on how to add single-line and block comments.

Joins: There is a discussion about INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN statements.

Other: There is also a discussion on how to combine columns, match parts of a string, and use if/then logic with the CASE and WITH statements.

Udacity’s SQL Cheat Sheets

Unlike the other online learning providers, Udacity does not have simple SQL cheat sheets. Instead, Udacity produces in-depth articles on different aspects of SQL.

Here is a list of Udacity’s most popular articles:

Final Thoughts on SQL Cheat Sheets

There are several SQL cheat sheets available online. Our favorites are from Codecademy, Dataquest, and Udacity because they are easy enough for beginners and robust enough for more advanced learners.

Share

Show Your Love

Read More

Related Reviews