☰ Learn SQL Tutorial Menu
The SELECT Statement
Written by Faisal Adnan · Updated 14 Oct 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;Result: first 5 of 26 rows (the order can differ on other engines unless you add ORDER BY)
| first_name | last_name | salary |
|---|---|---|
| Ali | Sheikh | 188000 |
| Sara | Qureshi | 149000 |
| Ahmed | Qureshi | 101000 |
| Ayesha | Sheikh | 77000 |
| Bilal | Ahmed | 122000 |
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;Result: first 5 of 26 rows (the order can differ on other engines unless you add ORDER BY)
| first_name | last_name | salary | annual_salary |
|---|---|---|---|
| Ali | Sheikh | 188000 | 2256000 |
| Sara | Qureshi | 149000 | 1788000 |
| Ahmed | Qureshi | 101000 | 1212000 |
| Ayesha | Sheikh | 77000 | 924000 |
| Bilal | Ahmed | 122000 | 1464000 |
Removing duplicates with DISTINCT
DISTINCT returns only unique values:
SELECT DISTINCT job_title FROM employees;Result: first 12 of 15 rows (the order can differ on other engines unless you add ORDER BY)
| job_title |
|---|
| Engineering Manager |
| Business Development Executive |
| SEO Specialist |
| HR Manager |
| Finance Manager |
| Support Team Lead |
| Financial Analyst |
| QA Engineer |
| Account Manager |
| Marketing Manager |
| HR Executive |
| Accountant |
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 XP for every lesson you finish.
Practice tip: the built-in code runner is being upgraded. Until it is back, copy the examples into any SQL or Python tool you have (for example SQLite, PostgreSQL, MySQL, SQL Server or a free online editor) and run them there. You can keep reading and earning XP here.
