Part 11: The SELECT Statement: Retrieving Columns & Aliasing

Part 11 Technology Updated September 12, 2026

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:

  1. Network Overhead: Transfers unnecessary columns across the wire.
  2. Breaks Covering Indexes: Forces the database to read table pages from disk rather than resolving the query from index memory alone.
  3. 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 AS to rename columns and computed expressions.

In Part 12, we will learn Eliminating Duplicates with SELECT DISTINCT!