Quick answer
SQL stands for Structured Query Language. It is used to work with data inside relational databases. With SQL, you can read records, filter rows, sort results, group information, join related tables, and change data when needed.
If you are brand new, the most important commands to learn first
are: SELECT, FROM, WHERE,
ORDER BY, and GROUP BY.
In this tutorial
What SQL is
SQL is the standard language for relational databases. A relational database stores data in tables made of rows and columns. Each row is one record. Each column stores one kind of value.
For example, a company might store employee data, sales data, order data, customer records, or inventory in database tables. SQL is how you pull that information out and work with it.
Common use
Read data for reports, dashboards, payroll checks, finance summaries, or app features.
Common jobs
Analysts, developers, BI teams, operations, product teams, and many technical business roles.
Why learn it
SQL is one of the most practical career skills because it helps you work directly with real business data.
Sample table
For this tutorial, imagine you have an employees table
like this:
| employee_id | name | department | salary | city |
|---|---|---|---|---|
| 1 | Ana | Sales | 62000 | Chicago |
| 2 | Ben | IT | 78000 | Dallas |
| 3 | Chris | HR | 56000 | Chicago |
| 4 | Dana | IT | 85000 | Denver |
Every query below will use this table so the examples stay simple.
SELECT: return data
The SELECT statement is how you read data from a table.
Select all columns
SELECT * FROM employees;
The * means all columns.
Select only certain columns
SELECT name, department, salary FROM employees;
*.
WHERE: filter rows
The WHERE clause lets you return only the rows that
match a condition.
Employees in IT
SELECT name, salary FROM employees WHERE department = 'IT';
Employees earning more than 60000
SELECT name, salary FROM employees WHERE salary > 60000;
Multiple conditions
SELECT name, department, city FROM employees WHERE department = 'IT' AND city = 'Dallas';
ORDER BY: sort results
Use ORDER BY when you want the results sorted.
Lowest to highest salary
SELECT name, salary FROM employees ORDER BY salary ASC;
Highest to lowest salary
SELECT name, salary FROM employees ORDER BY salary DESC;
Sort by department, then salary
SELECT name, department, salary FROM employees ORDER BY department ASC, salary DESC;
GROUP BY: summarize data
GROUP BY is used with aggregate functions like:
COUNT(), SUM(), AVG(),
MIN(), and MAX().
Count employees by department
SELECT department, COUNT(*) AS employee_count FROM employees GROUP BY department;
Average salary by department
SELECT department, AVG(salary) AS avg_salary FROM employees GROUP BY department;
GROUP BY as “bundle similar rows together,
then calculate something about each bundle.”
JOIN: combine related tables
A join connects rows from two tables using a shared key.
Imagine you also have a departments table:
| department | manager |
|---|---|
| Sales | Maria |
| IT | Jordan |
| HR | Lee |
Example INNER JOIN
SELECT e.name, e.department, d.manager FROM employees e INNER JOIN departments d ON e.department = d.department;
This returns each employee with the manager of that employee’s department.
INSERT, UPDATE, and DELETE
These commands change data rather than just reading it.
INSERT a new row
INSERT INTO employees (employee_id, name, department, salary, city) VALUES (5, 'Evan', 'Sales', 59000, 'Austin');
UPDATE a row
UPDATE employees SET salary = 80000 WHERE employee_id = 2;
DELETE a row
DELETE FROM employees WHERE employee_id = 5;
UPDATE or
DELETE without a WHERE clause can affect
the whole table.
Practice questions
Common beginner mistakes
-
Forgetting the
WHEREclause inUPDATEorDELETE - Using
SELECT *for everything - Assuming the database will sort rows automatically
- Getting confused about text values versus numeric values
- Trying to learn joins before understanding simple SELECT queries
Bottom line
SQL is one of the most practical skills you can learn for working
with data. Start with the basics: SELECT,
WHERE, and ORDER BY. Then move into
GROUP BY and joins once you are comfortable reading and
filtering rows.
Related: SQL Hub · SELECT Statement · How SQL Is Used at Work