Introduction to SELECT
TheSELECT statement is the most commonly used SQL command. It’s used to retrieve data from one or more tables.
Whenever you want to look at data stored in a table — like student names, scores, or results — you’ll use SELECT. It helps you fetch exactly what you need, no matter how large the table is.
Basic SELECT Syntax
The example below shows how to retrieve data from a table using the SELECT statement:
SELECT column1, column2 FROM table_name;
SELECTspecifies which columns to retrieve.FROMspecifies which table to retrieve the data from.
Select All Columns
The * is a wildcard that means "all columns".
SELECT * FROM mid_exam;
This query retrieves every column from the mid_exam table.
Example: View Names and Exam Scores
Let's say you have a table called mid_exam:
| id | name | exam_score | passed |
|---|---|---|---|
| 1 | John Miller | 78 | Yes |
| 2 | Emily Davis | 91 | Yes |
| 3 | Michael Johnson | 84 | Yes |
| 4 | Sophia Wilson | 65 | No |
| 5 | Ethan Brown | 88 | Yes |
You can retrieve student names and their exam scores using:
SELECT name, exam_score FROM mid_exam;
This returns:
| name | exam_score |
|---|---|
| John Miller | 78 |
| Emily Davis | 91 |
| Michael Johnson | 84 |
| Sophia Wilson | 65 |
| Ethan Brown | 88 |
Bonus: View Name and Passed Status
To check who passed the midterm, use:
SELECT name, passed FROM mid_exam;
Now you’ve seen how the SELECT command retrieves specific columns or the entire table.
It’s the first step toward mastering SQL — every data analysis or report starts with a simple SELECT query.
What SQL command is used to retrieve data from a table?
UPDATE
INSERT
SELECT
DELETE
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help
Code Editor
Tables
Execution Result