SELECT retrieves data from one or more tables. It's the statement you'll write more than any other in SQL.
Syntax
SELECT column1, column2
FROM table_name;
-- every column
SELECT * FROM table_name;
Sample Table: employees
| id | name | department | salary |
|---|---|---|---|
| 1 | Aman | Engineering | 65000 |
| 2 | Riya | Marketing | 52000 |
| 3 | Karan | Engineering | 71000 |
Example
SELECT name, department
FROM employees;
Output:
| name | department |
|---|---|
| Aman | Engineering |
| Riya | Marketing |
| Karan | Engineering |
Why Not Always Use SELECT *?
SELECT * is convenient while exploring data, but in real applications it's usually avoided: it pulls columns you don't need (wasting bandwidth and memory), and it silently breaks if the table's columns change later. Naming columns explicitly is the professional default.
Computed Columns
SELECT name, salary, salary * 12 AS annual_salary
FROM employees;
You can select expressions, not just raw columns — covered further in Aliases.
Common Mistakes
- Using
SELECT *in production application code instead of named columns - Forgetting that
SELECTalone doesn't filter or sort — that's WHERE and ORDER BY
Interview Relevance
The very first thing most SQL interviews check is whether you can write a clean, correctly-scoped SELECT — get comfortable with it before anything else.
Practice Question
Write a query that selects each employee's name and their salary expressed as a monthly figure, assuming salary stores an annual value.