Introduction: Data Everywhere in Our Daily Life
This tutorial is not technical or rigorous — it’s written from the perspective of a total beginner with zero coding background. If you’re not a programmer but want to get work done easily by harnessing SQL, this guide is for you.
I’m preparing a video based on this content, so this draft is also to gather feedback. I’ve created a discussion group too — beginners are very welcome to join!
Why Learn SQL?
Imagine you work in HR and handle employee data daily in Excel spreadsheets.
Most tasks are simple stats and basic table work, sometimes using manual methods but nothing too fancy.
Then one day, your boss asks you to analyze 20 years’ worth of stock market data and cross-check it with employee join dates. The question: Did stocks go up or down on the day each employee joined?
Without SQL, you’d have to manually dig through each date and stock record — a tedious, error-prone process. Yes, if you are an Excel macro expert, you could automate it, but for most people, macros are complicated.
If you know basic SQL, the answer is just 3 lines of code — merging two tables quickly.
And with just 4 lines of SQL, you get the full stats you need.
The key? You only need to learn about 10 SQL commands, which can be done in just two hours.
That’s exactly why I created this tutorial.
Quick Overview: The Four Lines of SQL Queries
Any SQL query basically follows this 4-line pattern, regardless of complexity. For better readability, we often split it into parts, but the structure remains:
- SELECT — What fields or results to show
- FROM — Which table(s) to query, including JOINs
- WHERE — Conditions to filter the data
- GROUP BY, ORDER BY, LIMIT — How to group, sort, or paginate the results
In total, there are about 7 main keywords you need to remember to start querying:
SELECT
FROM
INNER JOIN
WHERE
GROUP BY
ORDER BY
LIMIT
Basic SQL Examples Using Employee Data
Let’s assume you have an employee information table with columns like name, work number, age, gender, ID card, work address, etc.
Example 1: Select all data
SELECT *
FROM employee_info
Example 2: Select specific columns
SELECT name, workno, age
FROM employee_info
Example 3: Rename column for display
SELECT workaddress AS 'Work Address'
FROM employee_info
Example 4: Remove duplicates
SELECT DISTINCT workaddress AS 'Work Address'
FROM employee_info
Example 5: Count total employees
SELECT COUNT(*)
FROM employee_info
Example 6: Average employee age
SELECT AVG(age)
FROM employee_info
Example 7: Filter employees by age = 88
SELECT *
FROM employee_info
WHERE age = 88
Example 8: Filter age < 20
SELECT *
FROM employee_info
WHERE age < 20
Example 9: Employees without ID card
SELECT *
FROM employee_info
WHERE idcard IS NULL
Example 10: Age between 15 and 22
SELECT *
FROM employee_info
WHERE age BETWEEN 15 AND 22
Installation and Setup in 3 Simple Steps
Install a GUI SQL Client
You don’t need professional-grade tools. I recommend Navicat for beginners — it’s easy to use and powerful enough.Get a free MySQL server online
You can try free MySQL servers like SQLask — just create a database and user, then save the credentials carefully.Connect your SQL client to the server
Open Navicat, create a new connection with your server info, and you’re ready.
You can import Excel files directly into your database tables using the import wizard — no complex commands needed.
Practice and Answers
I’ve uploaded the sample database so you can connect and try these queries yourself.
Here are some example exercises and their answers:
# | Task | Example SQL Query |
---|---|---|
1 | Select name, work number, age | SELECT name, workno, age FROM employee_info |
5 | Employees aged 88 | SELECT * FROM employee_info WHERE age = 88 |
10 | Employees with no ID card | SELECT * FROM employee_info WHERE idcard IS NULL |
16 | Count employees | SELECT COUNT(*) FROM employee_info |
21 | Average age by gender | SELECT gender, AVG(age) FROM employee_info GROUP BY gender |
23 | Order employees by age ascending | SELECT * FROM employee_info ORDER BY age |
26 | First page of employees (10 per page) | SELECT * FROM employee_info LIMIT 0, 10 |
...and many more.
What's Next? Multi-table Queries
This tutorial currently focuses on single-table queries for simplicity. I’m planning to add multi-table JOINs and more advanced topics soon — please leave your feedback or join the discussion!
Bonus Tip: Practice SQL Locally with ServBay
If you want to experiment with SQL databases locally on your computer without complicated setups, I recommend trying ServBay. ServBay is a lightweight, serverless local environment tool that lets you easily launch multiple database instances, run queries, analyze performance, and avoid the risks of hitting production databases. It’s perfect for beginners and professionals alike to practice SQL in a safe, convenient way.
I hope this guide helps you get started with SQL easily — just like working in Excel but with way more power!
If you want to dive deeper or have any questions, feel free to reach out or join the learning group.
Happy querying! 🚀
Top comments (0)