☰ Learn SQL Tutorial Menu
The SELECT Statement
Written by CSA mentors · Updated 16 Sept 2026 · 3 min read
SELECT is the single most important SQL keyword — it's how you ask a database to return data.
Selecting everything
The * wildcard means "all columns":
SELECT * FROM employees;
Selecting specific columns
In real applications you almost always want only the columns you need — it's faster and clearer:
SELECT first_name, last_name, salary
FROM employees;
Renaming columns with aliases
Use AS to give a column (or expression) a friendlier name in the results:
SELECT first_name AS "First Name", salary AS monthly_salary
FROM employees;
AS is optional in most engines — salary monthly_salary works too — but writing it explicitly makes queries easier to read.
Computed columns
You can select expressions, not just raw columns:
SELECT first_name, last_name, salary, salary * 12 AS annual_salary
FROM employees;
Removing duplicates with DISTINCT
DISTINCT returns only unique values:
SELECT DISTINCT job_title FROM employees;
Limiting how many rows come back
Every engine supports this, but the keyword differs:
| Engine | Syntax |
|---|---|
| SQLite / PostgreSQL / MySQL | SELECT * FROM employees LIMIT 5; |
| SQL Server | SELECT TOP 5 * FROM employees; |
Open the Code Playground, pick any SQL engine (SQLite, PostgreSQL, MySQL, or SQL Server), and paste these queries in directly — the practice database above is already loaded for you, every time.
Lesson 3 of 27
Sign in to track your progress and earn learning points for every lesson you finish.
Example
-- A ready-to-query practice database is loaded automatically before every run —
-- no CREATE TABLE needed. Available tables:
-- departments (id, name, location)
-- employees (id, first_name, last_name, email, department_id, job_title, salary, hire_date, manager_id)
-- customers (id, customer_name, city, country, signup_date)
-- products (id, product_name, category, price, stock_quantity)
-- orders (id, customer_id, employee_id, order_date, status)
-- order_items (id, order_id, product_id, quantity, unit_price)
SELECT * FROM employees WHERE department_id = 1;
