Structured Query Language (SQL) is the standard language used to communicate with relational databases. It is widely applied across software development, data analysis, business intelligence, and backend systems. Because modern applications depend on structured data storage and retrieval, understanding SQL is a foundational skill for students, developers, and technical professionals working with data-driven systems.
About the book
SQL Basics Cheat Sheet is a concise reference guide focused on core SQL syntax and query patterns. The material centers on querying relational databases, joining multiple tables, filtering results, grouping data, and performing aggregate operations.
The document is intended for beginners learning SQL fundamentals as well as practitioners who need a compact reference for common commands and operations. It assumes familiarity with basic database concepts such as tables, rows, and columns, but it does not require advanced prior knowledge.
The content uses sample tables such as city and country to demonstrate how SQL statements operate in practice.
What you will learn
Readers will learn how to retrieve and filter data from a single table using SELECT statements, comparison operators, text operators, and ordering clauses. The guide explains how to combine multiple tables using different types of joins, including INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN, NATURAL JOIN, and CROSS JOIN.
It also covers aggregation and grouping through GROUP BY and HAVING clauses, along with commonly used aggregate functions such as COUNT, SUM, AVG, MIN, and MAX. The material introduces subqueries, including single-value, multiple-value, and correlated subqueries, and demonstrates how they interact with operators like IN and EXISTS.
Additionally, the cheat sheet explains set operations such as UNION, UNION ALL, INTERSECT, and EXCEPT, which allow combining or comparing result sets across multiple queries.
Table of contents
- SQL
- SAMPLE DATA
- ALIASES
COLUMNS
TABLES - QUERYING MULTIPLE TABLES
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL JOIN
NATURAL JOIN
CROSS JOIN - QUERYING SINGLE TABLE
- FILTERING THE OUTPUT
COMPARISON OPERATORS
TEXT OPERATORS
OTHER OPERATORS - AGGREGATION AND GROUPING
AGGREGATE FUNCTIONS
EXAMPLE QUERIES - SUBQUERIES
SINGLE VALUE
MULTIPLE VALUES
CORRELATED - SET OPERATIONS
UNION
INTERSECT
EXCEPT
Book details
- Title: SQL Basics Cheat Sheet
- Author(s): Vertabelo SA
- Main category: Databases
- Subcategory: SQL
- Language: English
- License: CC BY-NC-ND Vertabelo SA
Legal notice: This book is shared for educational purposes only. The content is distributed under Creative Commons licenses or with explicit permission from the author. FreeProgrammingBooks may host files that comply with their respective licenses.