SQL Tutorial with Exercises – MySQL

This tutorial illustrates the essential concepts of the MySQL SQL language in a easy to understand, well organized manner. This MySQL SQL tutorial provides comprehensive coverage of different topics, starting from basic SELECT statements and filtering rows, to sorting a result set, querying multiple tables, using various functions and creating new database structures.

In order to help you better understand different topics, most of these tutorials are accompanied by exercises (including solutions), allowing you to practice the MySQL SQL Language.

Please note – this SQL tutorial focuses on MySQL environment. If you want to learn SQL on a different platform, please use this link.

Basic SELECT Statement | Exercises 1 | Exercises 2 

The MySQL SELECT clause is used to query the database and retrieve selected rows. This guide explains the basic concepts of the MySQL SELECT statement, how to perform arithmetic operations, how to modify a column’s header using Column Aliases, how to concatenate string values, and how to retrieve unique records using the MySQL DISTINCT keyword.

Filtering and Sorting the Results
Exercises 1 | Exercises 2 

The MySQL WHERE clause is used to filter the number of rows returned by a SQL query, allowing you to retrieve specific information excluding irrelevant data. This tutorial explains how to use different MySQL Comparison Operators in order to get records that meet specific criteria. This tutorial also explains how to to sort the result set using the MySQL ORDER BY clause.

MySQL Scalar Functions | Exercises 1 | Exercises 2

Scalar Functions are used to carry out operations such as: mathematical tasks on numerical data, different manipulations on string and dates values, NULL-related operations, and datatypes conversions. This guide provides you a summary of some of the most common MySQL Built-in Scalar Functions

MySQL Group Functions | Exercises 1 | Exercises 2

MySQL Group functions are SQL functions that operate on groups of records, and for each group return one result. This tutorial lists some of the most common MySQL Group Functions, this tutorial also explains how to use the MySQL GROUP BY and the HAVING clauses.

Querying Multiple Tables | Exercises 1 | Exercises 2

A JOIN is a query that combine information from two or more tables, in MySQL there are different types of JOIN, used to achieve different goals. This tutorial explains the following JOIN types: Inner Join, Outer Join and Self Join.

Sub Queries | Exercises 1 | Exercises 2

A subquery in MySQL is used to run a separate query from within the main query, in many cases the returned value is used as a filter condition in a WHERE or a HAVING clause. This MySQL tutorial explains how to nest a query within another query in order to further restrict the data to be retrieved. This tutorial also describes the difference between two common types of subqueries: single-row and multiple-row.


DML (Data Manipulation Language) statements are used to modify information in a table in one of the three ways: INSERT – Adding new rows to a table. UPDATE – Modifies the data of a table, DELETE – Deletes one or more rows from a table. This tutorial demonstrates how to use these statements, explains how to use the MERGE statement, and briefly describes database transactions.


DDL (Data Definition Language) statements are used to create and alter database objects. This tutorial explains how to create a new table using the MySQL CREATE TABLE statement, how to modify the structure of existing table using the ALTER statement, and how to remove a table from the database using the DROP statement.

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…