ShareYourGroupShareYourGroupSQL

Lesson 1 of 26 · see the practice database

What SQL is, and your first query

A database is an organised store of information. A shop's database remembers its customers, its products and every order. A school's remembers students, classes and marks. SQL is the language you use to ask a database questions and to change what it holds. The letters stand for Structured Query Language. Some people say the letters one by one and others say "sequel". Both are fine.

SQL is worth learning because it is everywhere. Banks, hospitals, websites, apps and accounting software keep their data in databases that speak it. The language has changed little in decades, so what you learn here stays useful.

Tables, rows and columns

A database keeps its data in tables. A table looks like a sheet in a spreadsheet.

Our practice database belongs to a small made-up shop. It has five tables: customers, products, orders, order_items and employees. You can see all of them on the practice database page.

Your first query

A request to the database is called a query. This one asks for everything in the customers table.

SELECT * FROM customers;

Result

idnamecitystatejoinedemail
1Asha VermaLudhianaPunjab2025-01-15asha@example.com
2Ravi KumarDelhiDelhi2025-02-03ravi@example.com
3Meena GillAmritsarPunjab2025-03-21NULL
4Kabir KhanMumbaiMaharashtra2025-04-10kabir@example.com
5Sunita RaoChennaiTamil Nadu2025-05-05sunita@example.com
6Arjun MehtaPuneMaharashtra2025-06-18NULL
7Priya NairKochiKerala2025-07-02priya@example.com
8Imran AliDelhiDelhi2025-08-14imran@example.com
9Neha JoshiJaipurRajasthan2025-09-09neha@example.com
10Tara SinghLudhianaPunjab2025-10-27NULL
11Vikram DasKolkataWest Bengal2025-11-30vikram@example.com
12Joy ThomasMumbaiMaharashtra2026-01-08joy@example.com

12 rows

Read it as a sentence: "select everything from customers".

The database answers with a table of its own, called the result. Press Try it under any example to open it in the practice box, where you can change it and run it yourself. Nothing you do there can break anything. One button puts the database back as new.

Looking at another table

Change the table name and you get a different table.

SELECT * FROM products;

Result

idnamecategorypricestock
1Basmati Rice 5 kgGrocery65040
2Toor Dal 1 kgGrocery16075
3Sunflower Oil 1 LGrocery14560
4Tea 500 gGrocery2800
5Notebook 200 pagesStationery60300
6Ball Pen pack of 10Stationery90150
7Geometry BoxStationery12045
8School BagStationery75020
9LED Bulb 9 WElectronics110200
10Extension BoardElectronics39935
11EarphonesElectronics4990
12Power BankElectronics129918

16 rows

Showing the first 12 of 16 rows.

Each product has an id, a name, a category, a price in rupees and the number in stock. The id column is worth noticing. It gives every row a number of its own, so that two products with the same name could still be told apart. Nearly every table has such a column. It is called the primary key.

Does the case of the letters matter?

SQL keywords are not case sensitive. SELECT, select and Select all work. By habit, most people write the keywords in capitals and the table and column names in small letters, because it makes a query easier to read. These lessons follow that habit.

select * from employees;

Result

idnamedepartmentsalarymanager_idhired
1Anita KapoorManagement95000NULL2019-04-01
2Rohit BansalSales6000012020-06-15
3Deepa IyerSales4800022021-09-01
4Manoj YadavSales4800022022-01-10
5Farah SheikhWarehouse4200012020-11-20
6Gopal ReddyWarehouse3000052023-03-05
7Harpreet KaurSupport3600012021-02-14
8Nikhil JainSupport3300072024-07-22

8 rows

Spaces and line breaks do not matter either. A long query is usually spread over several lines, one part per line.

SELECT *
FROM orders;

Result

idcustomer_idorder_datestatus
112026-01-05delivered
222026-01-12delivered
342026-01-20cancelled
412026-02-02delivered
552026-02-14delivered
672026-02-28delivered
722026-03-03delivered
882026-03-15delivered
992026-03-22cancelled
1042026-04-01delivered
11112026-04-18delivered
1212026-05-06delivered

20 rows

Showing the first 12 of 20 rows.

When you make a mistake

If you misspell a table name, the database cannot find it and says so.

SELECT * FROM customer;

What the database says

Error: no such table: customer

The table is called customers, with an s. Error messages in SQL are short and usually name the word that caused the trouble. Read them. They save time.

What kind of SQL is this?

There are several database products: MySQL, PostgreSQL, SQL Server, Oracle, SQLite and others. All of them understand SQL, and the core of the language is the same in each. They differ in small ways, a little like the English of India, Britain and America. The practice box on this site runs SQLite. Wherever another product does something differently, the lesson tells you. There is a summary on the page about SQL in different databases.

What comes next

The next eight lessons are all about reading data: choosing columns, filtering rows, sorting and limiting. Reading is the largest part of SQL and the safest to practise, because a SELECT never changes anything.

Try it yourself

Exercise 1. Show everything in the orders table.

Solve it in the practice box

Show one answer
SELECT * FROM orders;
idcustomer_idorder_datestatus
112026-01-05delivered
222026-01-12delivered
342026-01-20cancelled
412026-02-02delivered
552026-02-14delivered
672026-02-28delivered
722026-03-03delivered
882026-03-15delivered
992026-03-22cancelled
1042026-04-01delivered
11112026-04-18delivered
1212026-05-06delivered

20 rows

Showing the first 12 of 20 rows.

Exercise 2. Show everything in the employees table.

Solve it in the practice box

Show one answer
SELECT * FROM employees;
idnamedepartmentsalarymanager_idhired
1Anita KapoorManagement95000NULL2019-04-01
2Rohit BansalSales6000012020-06-15
3Deepa IyerSales4800022021-09-01
4Manoj YadavSales4800022022-01-10
5Farah SheikhWarehouse4200012020-11-20
6Gopal ReddyWarehouse3000052023-03-05
7Harpreet KaurSupport3600012021-02-14
8Nikhil JainSupport3300072024-07-22

8 rows

Exercise 3. Show everything in the order_items table. How many columns does it have?

Solve it in the practice box

Show one answer
SELECT * FROM order_items;
order_idproduct_idquantity
112
121
154
294
2101
3121
432
441
5132
561
6141
7510

39 rows

Showing the first 12 of 39 rows.

Examples on this page were run with SQLite 3.50.4 on 12 November 2026. The results shown are the real results.

This is an independent learning site. It is not connected with the makers of any database product. MySQL, PostgreSQL, SQL Server, Oracle and SQLite are named only so that you know where a piece of SQL works. The shop, its customers and its staff in the practice database are made up.