SQL SELECT Statement
What is the SELECT Statement?
The SELECT statement is the most fundamental SQL command. It retrieves data from one or more tables in a database. Every SQL query you write starts with SELECT.
When you run a SELECT statement, the database engine reads the specified columns from the target table and returns them as a result set. You can select all columns using * or pick specific ones by name.
Syntax
SELECT column1, column2, ...
FROM table_name;To select every column:
SELECT * FROM table_name;When to Use
Use SELECT whenever you need to read data from the database:
- Viewing all records in a table
- Retrieving specific columns for a report
- Combining with
WHEREto filter results - Using expressions to compute values on the fly
Key Points
- Column Order — You control the order of columns in the result by listing them in the desired sequence.
- Expressions — You can use arithmetic, string functions, and other expressions directly in
SELECT. - Star Selector —
SELECT *returns all columns. In production, prefer naming columns explicitly for clarity and performance. - Case Insensitivity — SQL keywords like
SELECTandFROMare case-insensitive, but the convention is to write them in uppercase. - No Side Effects — A
SELECTstatement never modifies data; it only reads.
Mastering SELECT is the first step to becoming proficient in SQL. Every filter, join, and aggregation builds on top of this command.
Guided Practice
Solve the challenge below. Use hints when stuck and check your answer for instant feedback.
SQL SELECT Statement Challenge
Write a query that retrieve every column and every row from the students table.
Expected result
All rows from the students table with columns: id, first_name, last_name, email, age, grade.
Hidden checks
- Returned rows and values
- Output columns and result shape
- Final database state after the query runs
Lesson guidance
What is the SELECT Statement?
More Examples
Select specific columns
Retrieve only the name and email of each student.
Select with an expression
Calculate a value inline using an arithmetic expression.