The SQL SELECT Statement
The SELECT statement is used to retrieve data from one or more tables in a database. The data returned by a SELECT query is stored in a temporary result set, often called the result table. If you are new to SQL, make sure you have read Chapter 2: SQL Syntax first to understand the basic rules.
Here is the basic syntax:
SELECT column1, column2, ...
FROM table_name;
column1, column2— the names of the columns you want to retrievetable_name— the name of the table where the data is stored
We will use the following Employees table throughout this chapter:
+----+-----------+------------+--------+-----------+
| ID | Name | Department | Salary | City |
+----+-----------+------------+--------+-----------+
| 1 | Priya K. | Sales | 55000 | Mumbai |
| 2 | John D. | Marketing | 62000 | London |
| 3 | Arun M. | IT | 78000 | Delhi |
| 4 | Emma W. | Sales | 51000 | Sydney |
| 5 | Ravi S. | IT | 72000 | Mumbai |
| 6 | Sara L. | HR | 58000 | New York |
+----+-----------+------------+--------+-----------+
Select Specific Columns
To retrieve only certain columns, list their names after the SELECT keyword, separated by commas:
SELECT Name, City
FROM Employees;
+-----------+-----------+ | Name | City | +-----------+-----------+ | Priya K. | Mumbai | | John D. | London | | Arun M. | Delhi | | Emma W. | Sydney | | Ravi S. | Mumbai | | Sara L. | New York | +-----------+-----------+
Only the Name and City columns are returned. The database ignores all other columns because you did not ask for them.
Select All Columns with *
To retrieve every column in a table, use the asterisk (*) wildcard:
SELECT *
FROM Employees;
+----+-----------+------------+--------+-----------+ | ID | Name | Department | Salary | City | +----+-----------+------------+--------+-----------+ | 1 | Priya K. | Sales | 55000 | Mumbai | | 2 | John D. | Marketing | 62000 | London | | 3 | Arun M. | IT | 78000 | Delhi | | 4 | Emma W. | Sales | 51000 | Sydney | | 5 | Ravi S. | IT | 72000 | Mumbai | | 6 | Sara L. | HR | 58000 | New York | +----+-----------+------------+--------+-----------+
⚠️ When to Avoid SELECT *
Using SELECT * is convenient for quick exploration, but avoid it in production queries. It fetches more data than needed, slows down performance on large tables, and makes your query harder to understand. Always list the specific columns you need.
Select Multiple Specific Columns
You can select as many columns as you want by separating them with commas. The columns appear in the result in the same order you list them — not necessarily the order they appear in the table:
SELECT Department, Name, Salary
FROM Employees;
+------------+-----------+--------+ | Department | Name | Salary | +------------+-----------+--------+ | Sales | Priya K. | 55000 | | Marketing | John D. | 62000 | | IT | Arun M. | 78000 | | Sales | Emma W. | 51000 | | IT | Ravi S. | 72000 | | HR | Sara L. | 58000 | +------------+-----------+--------+
Notice that Department appears first in the output because it was listed first in the SELECT statement, even though it is the third column in the actual table.
SELECT with Column Aliases
You can rename columns in the output using the AS keyword. These renamed columns are called aliases. They do not change the actual table — only how the result is displayed:
SELECT Name AS EmployeeName,
Salary AS MonthlySalary
FROM Employees;
+--------------+---------------+ | EmployeeName | MonthlySalary | +--------------+---------------+ | Priya K. | 55000 | | John D. | 62000 | | Arun M. | 78000 | | Emma W. | 51000 | | Ravi S. | 72000 | | Sara L. | 58000 | +--------------+---------------+
Aliases are especially useful when column names are unclear or when you want to make reports more readable. You will learn more about aliases in Chapter 19: SQL Aliases.
SELECT with Simple Calculations
SQL can perform math directly inside a SELECT statement. You do not need a separate tool — the database calculates the result for every row:
SELECT Name,
Salary,
Salary * 12 AS AnnualSalary
FROM Employees;
+-----------+--------+--------------+ | Name | Salary | AnnualSalary | +-----------+--------+--------------+ | Priya K. | 55000 | 660000 | | John D. | 62000 | 744000 | | Arun M. | 78000 | 936000 | | Emma W. | 51000 | 612000 | | Ravi S. | 72000 | 864000 | | Sara L. | 58000 | 696000 | +-----------+--------+--------------+
The AnnualSalary column does not exist in the original table. SQL creates it on the fly by multiplying Salary * 12 for each row.
SELECT with Text Values
You can also select fixed text values alongside columns. This is useful for adding labels or status markers to your output:
SELECT Name,
Department,
'Active' AS Status
FROM Employees;
+-----------+------------+--------+ | Name | Department | Status | +-----------+------------+--------+ | Priya K. | Sales | Active | | John D. | Marketing | Active | | Arun M. | IT | Active | | Emma W. | Sales | Active | | Ravi S. | IT | Active | | Sara L. | HR | Active | +-----------+------------+--------+
💡 SELECT Variations Summary
| Syntax | What It Does |
|---|---|
SELECT col1, col2 |
Retrieves specific columns |
SELECT * |
Retrieves all columns |
SELECT col AS alias |
Renames a column in the output |
SELECT col * 12 |
Performs a calculation |
SELECT 'text' AS col |
Adds a fixed text column |
Once you are comfortable with SELECT, the next step is filtering your results with the SQL WHERE clause or removing duplicates with SELECT DISTINCT. For a complete reference of the SELECT syntax, see the official MySQL SELECT documentation.
If you work with data regularly, explore our ready-made Dashboard Templates on NextGenTemplates that use SQL-powered data for business reporting.
📺 Visit our YouTube channel @NeoTechNavigators for step-by-step video tutorials and dashboard demos on this topic.
🧪 Try It Yourself
Write a SELECT statement that shows each employee’s Name, City, and their Salary increased by 10% (label the new column RevisedSalary). Try it yourself before checking the answer.
SELECT Name,
City,
Salary * 1.10 AS RevisedSalary
FROM Employees;
Expected Output:
+-----------+-----------+---------------+ | Name | City | RevisedSalary | +-----------+-----------+---------------+ | Priya K. | Mumbai | 60500.0 | | John D. | London | 68200.0 | | Arun M. | Delhi | 85800.0 | | Emma W. | Sydney | 56100.0 | | Ravi S. | Mumbai | 79200.0 | | Sara L. | New York | 63800.0 | +-----------+-----------+---------------+
📝 What You Learned in This Chapter
SELECTis used to retrieve data from a table- List specific column names separated by commas to get only the data you need
- Use
SELECT *to get all columns (but avoid it in production) - The order of columns in your SELECT determines the order in the output
- Use
ASto create column aliases for cleaner output - SQL can perform math calculations (
Salary * 12) directly in SELECT - You can add fixed text values alongside real data columns
Frequently Asked Questions
*) is a wildcard that means “all columns.” When you write SELECT * FROM table_name, the database returns every column in that table. It is useful for quick data exploration but should be avoided in production queries because it fetches unnecessary data and can slow down performance.+, -, *, and / operators on numeric columns. For example, SELECT Price * Quantity AS Total FROM Orders calculates a new column on the fly without modifying the table.AS keyword. It does not change the actual column name in the database — it only renames it in the output. You can learn advanced alias techniques in Chapter 19: SQL Aliases.📖 Chapter 3 of 30 — SQL Tutorial on Neotech Navigators



