
Practical and Project-Based SQL
From Zero to Hero: Building a Simple Customer Database with SQL
Let’s start by creating a simple Customers table.
CREATE TABLE Customers (
ID INT PRIMARY KEY,
Name VARCHAR(50),
City VARCHAR(50),
Phone VARCHAR(20)
);
Insert sample data:
INSERT INTO Customers (ID, Name, City, Phone)
VALUES
(1, 'Alice', 'London', '555-1234'),
(2, 'Bob', 'Paris', '555-5678'),
(3, 'Charlie', 'New York', '555-8765');
Table looks like:
+----+---------+----------+----------+
| ID | Name | City | Phone |
+----+---------+----------+----------+
| 1 | Alice | London | 555-1234 |
| 2 | Bob | Paris | 555-5678 |
| 3 | Charlie | New York | 555-8765 |
+----+---------+----------+----------+
Top 10 Essential SQL Commands Every Beginner Should Know
CREATE TABLE
– build a tableINSERT INTO
– add dataSELECT
– view dataWHERE
– filter resultsORDER BY
– sort resultsUPDATE
– change dataDELETE
– remove dataJOIN
– combine tablesGROUP BY
– group dataCOUNT / SUM / AVG
– summarize data
A Beginner's Project: Analyzing Sales Data with Basic SQL
Sample Sales table:
+----+----------+--------+
| ID | Product | Amount |
+----+----------+--------+
| 1 | Laptop | 1000 |
| 2 | Phone | 500 |
| 3 | Laptop | 800 |
+----+----------+--------+
Example: Find total sales per product:
SELECT Product, SUM(Amount) AS TotalSales
FROM Sales
GROUP BY Product;
Result:
+---------+------------+
| Product | TotalSales |
+---------+------------+
| Laptop | 1800 |
| Phone | 500 |
+---------+------------+
Common SQL Mistakes and How to Avoid Them
Forgetting the WHERE clause when updating or deleting (can change all rows!).
Using
SELECT *
instead of selecting only needed columns.Forgetting to add a PRIMARY KEY, leading to duplicate data.
Mixing up WHERE vs. HAVING.
Putting It All Together: A Comprehensive SQL Fundamentals Review
By now, you’ve learned:
How to build a table and insert data
How to query with SELECT, WHERE, ORDER BY
How to modify data with UPDATE and DELETE
How to combine tables with JOIN
How to summarize data with GROUP BY
These are the core SQL fundamentals every beginner should master.
✅ Pro Tip
When practicing SQL, always create small sample projects (like a customer or sales database). This makes learning fun, practical, and much easier to remember compared to just memorizing commands.