SQL SELECT
SQL

SQL SELECT — How to Retrieve Data from a Database Table

CHAPTER 3 of 30 SQL Tutorial — Free Course on Neotech Navigators
The SQL SELECT statement is the foundation of SQL. It is the command you will use more than any other — every time you want to read, view, or retrieve data from a database, you use SELECT. In this chapter, you will learn how to select specific columns, all columns, and how to format your SELECT queries properly.

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:

SQL — SELECT Syntax
SELECT column1, column2, ...
FROM table_name;
  • column1, column2 — the names of the columns you want to retrieve
  • table_name — the name of the table where the data is stored

We will use the following Employees table throughout this chapter:

TABLE: 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  |
+----+-----------+------------+--------+-----------+

Select Specific Columns

To retrieve only certain columns, list their names after the SELECT keyword, separated by commas:

SQL
SELECT Name, City
FROM Employees;
✓ OUTPUT
+-----------+-----------+
| 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:

SQL
SELECT *
FROM Employees;
✓ OUTPUT
+----+-----------+------------+--------+-----------+
| 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:

SQL
SELECT Department, Name, Salary
FROM Employees;
✓ OUTPUT
+------------+-----------+--------+
| 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:

SQL
SELECT Name AS EmployeeName,
       Salary AS MonthlySalary
FROM Employees;
✓ OUTPUT
+--------------+---------------+
| 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:

SQL
SELECT Name,
       Salary,
       Salary * 12 AS AnnualSalary
FROM Employees;
✓ OUTPUT
+-----------+--------+--------------+
| 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:

SQL
SELECT Name,
       Department,
       'Active' AS Status
FROM Employees;
✓ OUTPUT
+-----------+------------+--------+
| 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.

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

  • SELECT is 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 AS to 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

What does SELECT * mean in SQL?
The asterisk (*) 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.
Does the order of columns in SELECT matter?
Yes — the columns appear in your result set in the exact order you list them in the SELECT statement. This does not affect the actual data in the table; it only controls how the output is displayed.
Can I use calculations in a SELECT statement?
Absolutely. SQL supports arithmetic operations directly in SELECT. You can use +, -, *, 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.
What is a column alias in SQL?
A column alias is a temporary name given to a column in the result set using the 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.
How many columns can I select in one query?
There is no practical limit on the number of columns you can select. You can list as many columns as the table contains. However, for performance and readability, it is best practice to select only the columns you actually need rather than selecting everything.

📖 Chapter 3 of 30 — SQL Tutorial on Neotech Navigators

PK
Meet PK, the founder of NeotechNavigators.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your data analysis skills to the next level!
https://neotechnavigators.com