You’ve created a table and inserted data into it. Now it’s time to learn the most fundamental command for retrieving that data: SELECT
.
The SELECT
statement is used to query the database and retrieve data that matches criteria that you specify.
Selecting All Data from a Table
The simplest way to use SELECT
is to retrieve every column from every row in a table. To do this, you use the asterisk (*
), which is a shorthand for “all columns”.
Let’s see all the data in our `Friends` table:
SELECT * FROM Friends;
Let’s break it down:
SELECT *
: This means “select all columns”.FROM Friends
: This specifies the table from which we want to retrieve data, which is our `Friends` table.
The result will be a complete table showing the ID, Name, and PhoneNumber of all three friends we inserted in the previous lecture.
Selecting Specific Columns
What if you only want to see the names of your friends, but not their phone numbers? You can do this by specifying the exact column(s) you want to see instead of using *
.
To select only the `Name` column, you would use this command:
SELECT Name FROM Friends;
This will return a single column containing the names: Sarah, John, and Maria.
You can also select multiple specific columns by separating them with a comma. If you want to see the name and phone number but not the ID, you would write:
SELECT Name, PhoneNumber FROM Friends;

The Power of SELECT
This might seem simple now, but the SELECT
statement is the foundation for almost everything you will do in SQL. We will build on this command in the upcoming lectures, adding powerful new clauses to filter, sort, and group data to get the exact information you need.
In the Next Lecture…
What if you only wanted to see the phone number for one specific friend? In the next lecture, we will learn how to filter our results using the WHERE
clause to find specific rows in our table.