Part 11: The SELECT Statement: Retrieving Columns & Aliasing
The SELECT statement is the foundation of Data Query Language (DQL).
1. Basic Syntax
-- Retrieve all columns (Avoid in production!):
SELECT * FROM employees;
-- Retrieve specific columns (Best practice):
SELECT first_name, last_name, salary FROM employees;
Why SELECT * is an Antipattern in Production:
- Network Overhead: Transfers unnecessary columns across the wire.
- Breaks Covering Indexes: Forces the database to read table pages from disk rather than resolving the query from index memory alone.
- Application Fragility: Adding a column can break client code relying on ordinal column positions.
2. Column Aliasing with AS
Rename output columns for clarity or presentation:
SELECT
first_name AS "First Name",
last_name AS "Last Name",
salary * 12 AS annual_salary
FROM employees;
Key Takeaways
- Always specify column names explicitly; avoid
SELECT *in production. - Use
ASto rename columns and computed expressions.
In Part 12, we will learn Eliminating Duplicates with SELECT DISTINCT!

