Learn SQL Queries With Examples: Master The Basics Quickly

Robert Jul 13, 2026

Welcome to your comprehensive guide on learning SQL queries with hands-on examples. SQL, or Structured Query Language, is a crucial skill for managing and manipulating databases. Let's dive right in and start practicing.

SQL Subqueries Explained with Examples | Beginner SQL Tutorial
SQL Subqueries Explained with Examples | Beginner SQL Tutorial

Before we begin, ensure you have a database like MySQL or PostgreSQL installed, and create a sample database for practicing these queries. We'll use a simple 'Employees' table for demonstration:

SQL Subqueries Made Easy 🔍 | Nested Queries with Examples
SQL Subqueries Made Easy 🔍 | Nested Queries with Examples

| EmployeeID | FirstName | LastName | Department | Salary | |---|---|---|---|---| | 1 | John | Doe | IT | 60000 | | 2 | Jane | Smith | HR | 55000 | | 3 | Michael | Johnson | IT | 65000 | | 4 | Emily | Davis | Finance | 70000 | | 5 | Robert | Brown | HR | 50000 |

Basic SQL Queries

Let's start with the foundation of SQL - SELECT, INSERT, UPDATE, and DELETE queries.

SQL Quick Notes Cheat Sheet | SQL Queries, Joins, Functions & Database Commands for Beginners
SQL Quick Notes Cheat Sheet | SQL Queries, Joins, Functions & Database Commands for Beginners

Selecting Data

The SELECT query is used to retrieve data from a database. Here's a basic query to fetch all columns from the 'Employees' table:

SQL ORDER BY Explained with Examples | Sort Data in SQL
SQL ORDER BY Explained with Examples | Sort Data in SQL

SELECT * FROM Employees;

You can also specify columns to fetch. For instance, to fetch only 'FirstName', 'LastName', and 'Department', use:

SELECT FirstName, LastName, Department FROM Employees;

SQL Basics Tutorial for Beginners – Structured Query Language Commands, Syntax & Examples Guide
SQL Basics Tutorial for Beginners – Structured Query Language Commands, Syntax & Examples Guide

Inserting Data

To insert new records, use the INSERT INTO query. Add a new employee named 'David Wilson' to the 'Finance' department with a salary of 75000:

INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (6, 'David', 'Wilson', 'Finance', 75000);

SQL SUM() Explained with Examples | Beginner SQL Tutorial
SQL SUM() Explained with Examples | Beginner SQL Tutorial

Advanced SQL Queries

Now that we've covered the basics, let's explore more complex queries.

SQL CASE WHEN Explained with Examples | Beginner SQL Tutorial
SQL CASE WHEN Explained with Examples | Beginner SQL Tutorial
SQL AND vs OR Explained with Examples | Beginner SQL Tutorial
SQL AND vs OR Explained with Examples | Beginner SQL Tutorial
SQL LIMIT Explained with Examples | Beginner SQL Tutorial
SQL LIMIT Explained with Examples | Beginner SQL Tutorial
SQL CTE Explained with Examples | Common Table Expression Tutorial
SQL CTE Explained with Examples | Common Table Expression Tutorial
SQL NULLIF() Explained with Examples | Prevent Divide by Zero Errors in SQL
SQL NULLIF() Explained with Examples | Prevent Divide by Zero Errors in SQL
SQL LEFT JOIN Explained with Examples | Beginner SQL Tutorial
SQL LEFT JOIN Explained with Examples | Beginner SQL Tutorial
SQL GROUP BY Explained with Examples | Beginner SQL Tutorial
SQL GROUP BY Explained with Examples | Beginner SQL Tutorial
SQL IN Operator Explained with Examples | Beginner SQL Tutorial
SQL IN Operator Explained with Examples | Beginner SQL Tutorial
Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts
Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts
SQL BETWEEN Explained with Examples | Beginner SQL Tutorial
SQL BETWEEN Explained with Examples | Beginner SQL Tutorial
SQL WHERE Clause Explained with Examples | Beginner SQL Tutorial
SQL WHERE Clause Explained with Examples | Beginner SQL Tutorial
SQL INNER JOIN Explained with Examples | Beginner SQL Tutorial
SQL INNER JOIN Explained with Examples | Beginner SQL Tutorial
SQL Cheat Sheet for Beginners
SQL Cheat Sheet for Beginners
SQL Joins Explained 🚀 | Beginner Data Analyst SQL Guide
SQL Joins Explained 🚀 | Beginner Data Analyst SQL Guide
SQL MIN() Explained with Examples | Beginner SQL Tutorial
SQL MIN() Explained with Examples | Beginner SQL Tutorial
THE SQL CIRCLE
THE SQL CIRCLE
SQL RIGHT() Explained with Examples | Extract Characters from the Right in SQL Server
SQL RIGHT() Explained with Examples | Extract Characters from the Right in SQL Server
Complete SQL Cheat Sheet for Beginners | SQL Commands, Joins, Queries & Database Guide
Complete SQL Cheat Sheet for Beginners | SQL Commands, Joins, Queries & Database Guide
SQL queries don
SQL queries don

Updating Data

To update existing records, use the UPDATE query. Suppose Michael Johnson got a raise and his new salary is 70000:

UPDATE Employees SET Salary = 70000 WHERE EmployeeID = 3;

Deleting Data

To delete records, use the DELETE query. If you want to remove Robert Brown from the 'Employees' table:

DELETE FROM Employees WHERE EmployeeID = 5;

Next, we'll explore ways to filters data using WHERE clauses and sort results using ORDER BY.

Keen to learn more? Explore SQL joins, subqueries, and aggregate functions next. Happy coding!