SQL Introduction
SQL

SQL Introduction: What Is SQL and How Databases Use It

SQL Tutorial · Chapter 1 of 32

SQL (Structured Query Language) is the standard language for storing, retrieving and changing data in a relational database. With a handful of English-like keywords such as SELECT, INSERT, UPDATE and DELETE you can ask a database a question and get back exactly the rows you need. This SQL introduction explains what SQL is, how tables are organised and how to run your first query.

What Is a Relational Database?

A relational database stores data in tables. Each table has named columns (fields) and any number of rows (records). Tables are linked through shared key columns: an Orders table stores a CustomerID that points to one row in the Customers table. Popular relational database systems include MySQL, PostgreSQL, SQL Server, Oracle and SQLite, and every one of them understands SQL.

Sample Tables Used in This Course

Every chapter of this course uses the same two small tables, so you can follow along and predict each result yourself before reading it.

Customers
CustomerID Name City Country
1 Anita Sharma Mumbai India
2 John Smith London UK
3 Maria Garcia Madrid Spain
4 Wei Chen Singapore Singapore
5 Emma Brown Sydney Australia
Orders
OrderID CustomerID Product Amount OrderDate
101 1 Laptop 1200 2026-01-05
102 2 Mouse 25 2026-01-07
103 1 Monitor 300 2026-01-12
104 3 Keyboard 45 2026-02-02
105 6 Headset 80 2026-02-15
106 4 Laptop 1150 2026-03-01

Basic SQL Syntax

SELECT column1, column2
FROM table_name
WHERE condition;

A statement is built from keywords (SELECT, FROM, WHERE), identifiers (table and column names) and values (text in single quotes, numbers without quotes). Statements end with a semicolon. Keywords are not case sensitive, but writing them in capitals makes queries easier to read.

Example 1: Your First Query

SELECT * returns every column of every row in a table.

SELECT * FROM Customers;
CustomerID Name City Country
1 Anita Sharma Mumbai India
2 John Smith London UK
3 Maria Garcia Madrid Spain
4 Wei Chen Singapore Singapore
5 Emma Brown Sydney Australia

Example 2: Choose Specific Columns

SELECT Name, City FROM Customers;
Name City
Anita Sharma Mumbai
John Smith London
Maria Garcia Madrid
Wei Chen Singapore
Emma Brown Sydney

Example 3: Filter Rows

SELECT Name, Country FROM Customers
WHERE Country = 'India';
Name Country
Anita Sharma India

Example 4: Count Rows

SELECT COUNT(*) AS TotalOrders FROM Orders;
TotalOrders
6

The Main Categories of SQL Commands

Category Commands Purpose
Query (DQL) SELECT Read data
Manipulation (DML) INSERT, UPDATE, DELETE Add, change or remove rows
Definition (DDL) CREATE, ALTER, DROP Create or change tables
Control (DCL) GRANT, REVOKE Manage permissions
Transactions (TCL) COMMIT, ROLLBACK Save or undo a batch of changes

Most day-to-day work, and most of this course, is SELECT.

Works in MySQL, SQL Server, PostgreSQL, SQLite

Core SQL is standardised (ANSI SQL), so SELECT, WHERE, JOIN and GROUP BY behave the same in all four systems. Differences appear at the edges: limiting rows (LIMIT vs TOP), string and date functions, and data type names. Each chapter of this course points out those differences where they matter.

Why Learn SQL?

  • It is the most requested skill in data analyst, BI and reporting job listings.
  • Excel, Power BI, Google Sheets and Python can all pull data straight from SQL queries.
  • A basic query takes minutes to learn, yet the same language scales to billions of rows.

How to Follow This Course

Each chapter shows the query and the exact result it produces on the sample tables above, so you can read straight through or type every example into a free online SQLite editor. The chapters build on each other: filtering comes before aggregation, aggregation before joins. Finish with the reference and the 75-question quiz to check what you have learned.

Common Mistakes

  • Forgetting single quotes around text values: WHERE Country = India fails, WHERE Country = 'India' works.
  • Misspelling a table or column name; the database cannot guess what you meant.
  • Assuming keywords are case sensitive; select and SELECT are identical.

Practice Exercise

  1. Write a query that returns the Product and Amount of every order.
  2. Write a query that counts how many customers are in the Customers table.
Show answers
-- 1
SELECT Product, Amount FROM Orders;

-- 2
SELECT COUNT(*) AS TotalCustomers FROM Customers;
-- TotalCustomers = 5

Related Chapters

FAQ

Is SQL a programming language?

SQL is a declarative query language: you describe the result you want and the database works out how to produce it. It is not a general-purpose programming language, but it is often used alongside Python, Java or VBA.

Which database should a beginner install?

SQLite needs no installation and runs in free tools such as DB Browser for SQLite or online editors. MySQL and PostgreSQL are free too and are the most common choices for web applications.

How long does it take to learn SQL?

Most learners can write useful SELECT queries with filters and joins after a few hours of practice. This course covers the full beginner-to-intermediate path in about four hours of reading.

Chapter 1 of 32 · SQL from Scratch: all 32 chapters

PK
Meet PK, the founder of NeotechNavigators.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your data analysis skills to the next level!
https://neotechnavigators.com