Lecture

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:

Basic SELECT Syntax
SELECT column1, column2 FROM table_name;
  • SELECT specifies which columns to retrieve.
  • FROM specifies which table to retrieve the data from.

Select All Columns

The * is a wildcard that means "all columns".

Select 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:

idnameexam_scorepassed
1John Miller78Yes
2Emily Davis91Yes
3Michael Johnson84Yes
4Sophia Wilson65No
5Ethan Brown88Yes

You can retrieve student names and their exam scores using:

Select name and exam score
SELECT name, exam_score FROM mid_exam;

This returns:

nameexam_score
John Miller78
Emily Davis91
Michael Johnson84
Sophia Wilson65
Ethan Brown88

Bonus: View Name and Passed Status

To check who passed the midterm, use:

Select name and passed status
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.

Quiz
0 / 1

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

Run
Generate

Tables

Execution Result