SELECT & Data Retrieval: Functions
Module: SQL Fundamentals
SELECT column1, column2, column3
FROM table_name;
SELECT * FROM table_name;
SELECT
first_name AS name,
salary * 12 AS annual_salary,
CONCAT(first_name, ' ', last_name) AS full_name
FROM employees;
SELECT
product_name,
price,
price * 0.9 AS discounted_price,
price * 1.1 AS price_with_tax
FROM products;
SELECT DISTINCT department FROM employees;
SELECT DISTINCT department, job_title FROM employees;
SELECT is required - every query starts with SELECT
FROM clause specifies the table - required except for constant expressions
Column names are comma-separated - no comma after last column
AS keyword for aliases is optional but recommended for readability
DISTINCT applies to entire row, not individual columns
SELECT * means all columns in table definition order
Logical execution order: FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → LIMIT
WHERE cannot use SELECT aliases (WHERE executes before SELECT projection)
Core references in this topic include WHERE, =, <, >, <=, >=. Learn what each one does, when to use it, and the execution or engine rules that matter.
WHERE
Filters rows before projection and sorting. It decides which rows continue through the query pipeline.
SELECT ... FROM table WHERE condition;
Most performance issues start with a weak WHERE clause or a missing supporting index.
=
Returns rows where the left and right values are exactly equal.
column = value
Use with exact matches. Do not use = NULL.
<, >, <=, >=
Range comparison operators for less-than, greater-than, and inclusive boundary checks.
salary >= 80000
BETWEEN
Checks whether a value falls inside an inclusive lower/upper range.
order_total BETWEEN 100 AND 500
ANY / ALL