Skip to content

Viewing Your Data with SELECT | Lecture 6

A Closer Look at Data Types

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;
Viewing Your Data with SELECT
Putting Data into Your Table

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.

Putting Data into Your Table | Lecture 5

Najeeb Alam

Najeeb Alam

Technical writer specializes in developer, Blogging and Online Journalism. I have been working in this field for the last 20 years.