The SELECT statement is the most frequently used command in MySQL. It is the R in CRUD — Read. Every time you want to retrieve data from a table — whether one row or millions — you use SELECT. Everything from simple lookups to complex multi-table reports is built on this single statement.
SELECT column1, column2, ...
FROM table_name;
The clauses that can follow FROM — like WHERE, ORDER BY, and LIMIT — are all optional. They each get their own dedicated lesson later in this series.
All examples on this page use the following students table:
| id | name | city | age |
|---|---|---|---|
| 1 | Rahim Uddin | Dhaka | 22 |
| 2 | Sara Begum | Chittagong | 20 |
| 3 | Karim Ali | Sylhet | 23 |
| 4 | Nila Akter | Dhaka | 21 |
| 5 | Rafi Hossain | Rajshahi | 24 |
The asterisk * is a wildcard that means "all columns". Use it when you want every column returned:
SELECT * FROM students;
This returns all 5 rows with all 4 columns exactly as shown in the table above.
SELECT * is convenient for quick exploration, avoid it in production code. Listing columns explicitly makes queries faster, more predictable, and easier to maintain.
List only the columns you need, separated by commas:
SELECT name, city FROM students;
| name | city |
|---|---|
| Rahim Uddin | Dhaka |
| Sara Begum | Chittagong |
| Karim Ali | Sylhet |
| Nila Akter | Dhaka |
| Rafi Hossain | Rajshahi |
You can rename a column in the result set using AS. The alias only affects the output — the actual column name in the table is unchanged:
SELECT name AS student_name, city AS hometown
FROM students;
| student_name | hometown |
|---|---|
| Rahim Uddin | Dhaka |
| Sara Begum | Chittagong |
| Karim Ali | Sylhet |
| Nila Akter | Dhaka |
| Rafi Hossain | Rajshahi |
You are not limited to column names — you can include any expression or calculation:
-- Add 1 to every student's age in the result
SELECT name, age, age + 1 AS next_year_age
FROM students;
-- Combine first and last name columns into one
SELECT CONCAT(first_name, ' ', last_name) AS full_name
FROM employees;
The calculation happens at query time and does not change any data stored in the table.
Use WHERE to filter results and return only rows that match a condition. The WHERE clause is covered in full detail in its own lesson, but here is a quick preview:
-- Return only students from Dhaka
SELECT name, age FROM students
WHERE city = 'Dhaka';
| name | age |
|---|---|
| Rahim Uddin | 22 |
| Nila Akter | 21 |
Use ORDER BY to sort results. ASC (ascending) is the default; use DESC for descending:
-- Sort students by age, youngest first
SELECT name, age FROM students
ORDER BY age ASC;
LIMIT restricts how many rows are returned — useful for pagination or previewing data:
-- Return the first 3 students only
SELECT name, city FROM students
LIMIT 3;
All clauses can be combined in a single query. The order must always follow this structure:
SELECT name, city, age
FROM students
WHERE age > 20
ORDER BY age DESC
LIMIT 3;
SELECT → FROM → WHERE → ORDER BY → LIMIT. MySQL will return an error if the clauses appear in the wrong order.
SELECT * returns all columns — use it for exploration, not for production queries.AS to give columns a friendlier name in the result — the table itself is not changed.SELECT list.WHERE to filter, ORDER BY to sort, and LIMIT to cap the number of results.SELECT → FROM → WHERE → ORDER BY → LIMIT.