Quick answer
The SELECT statement is used to retrieve data from a database table.
It is the most important SQL command because nearly every query starts with it.
SELECT column_name FROM table_name;
In simple terms:
SELECTtells SQL what data you wantFROMtells SQL where to get it
SELECT.
In this guide
Sample table
Imagine you have this table called employees:
| 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 |
Why SELECT matters
The SELECT statement is the foundation of SQL. Before you learn joins, grouping, ordering, or updates, you need to understand how to retrieve data correctly.
In real work, SELECT is used for things like:
- showing a list of customers
- finding employees in a certain department
- viewing salaries, dates, names, or totals
- checking records before making changes with UPDATE or DELETE
Select all columns
You can retrieve every column in a table with an asterisk.
SELECT * FROM employees;
This returns all columns and all rows from the employees table.
| 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 |
SELECT * is useful for quick exploration, but in real projects it is usually better to select only the columns you actually need.
Select specific columns
Most of the time, you do not need every column. You can request only the ones you want.
SELECT name, salary FROM employees;
This returns just the employee name and salary.
| name | salary |
|---|---|
| Ana | 62000 |
| Ben | 78000 |
| Chris | 56000 |
| Dana | 85000 |
Use WHERE to filter rows
A basic SELECT query returns all rows unless you filter them.
The WHERE clause lets you choose only rows that match a condition.
SELECT name, salary FROM employees WHERE salary > 60000;
This returns only employees with a salary above 60000.
| name | salary |
|---|---|
| Ana | 62000 |
| Ben | 78000 |
| Dana | 85000 |
Use aliases
Aliases let you rename columns in your result. This is helpful when the original column name is too technical or when you want a cleaner output label.
SELECT name AS employee_name, salary AS annual_salary FROM employees;
This changes the labels shown in the result to employee_name and annual_salary.
Use ORDER BY
Results are not guaranteed to come back in a meaningful order unless you sort them.
That is what ORDER BY is for.
SELECT name, salary FROM employees ORDER BY salary DESC;
This sorts employees from highest salary to lowest salary.
| name | salary |
|---|---|
| Dana | 85000 |
| Ben | 78000 |
| Ana | 62000 |
| Chris | 56000 |
DESC means descending. Use it when you want the biggest values first.
Use LIMIT
Sometimes you only want the first few results instead of everything.
The LIMIT clause helps with that.
SELECT name, salary FROM employees ORDER BY salary DESC LIMIT 2;
This returns only the top 2 highest salaries.
| name | salary |
|---|---|
| Dana | 85000 |
| Ben | 78000 |
Common mistakes
- using
SELECT *everywhere, even when only a few columns are needed - forgetting
WHEREwhen filtering is required - assuming results come back in a stable order without
ORDER BY - selecting too many columns and making the result harder to read
- confusing aliases with real column names
ORDER BY.
Practice questions
Bottom line
The SELECT statement is the core of SQL.
Once you understand how to select columns, filter rows, sort results, and limit output, you are ready to build much more advanced queries.
Related SQL tutorials
Start here for all SQL topics and tutorials.
Learn how to filter rows after selecting data.
Learn how to sort query results correctly.
Learn how to group selected data into summaries.