☰ 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_namelast_namesalary
AliSheikh188000
SaraQureshi149000
AhmedQureshi101000
AyeshaSheikh77000
BilalAhmed122000

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_namelast_namesalaryannual_salary
AliSheikh1880002256000
SaraQureshi1490001788000
AhmedQureshi1010001212000
AyeshaSheikh77000924000
BilalAhmed1220001464000

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:

EngineSyntax
SQLite / PostgreSQL / MySQLSELECT * FROM employees LIMIT 5;
SQL ServerSELECT 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.