Instructor: Hi guys and welcome back.
In this video we're going to deconstruct
the Select statement for you.
Here we've got an example,
SELECT first_name, surname FROM users.
The first part tells the database
that we want to find and retrieve data.
That's what the SELECT is for.
Then the columns that we want to retrieve data from,
or what we want the final result set to contain.
And in the final result set, we're gonna get the
first_name and surname columns of the users table.
Note that, if the users table had five columns, let's say,
we would only get data from the first_name
and surname columns.
There's a lot more to do with SELECT.
We can filter the selected data
so that we only get rows with certain values,
and we can use the WHERE clause for that.
We're gonna use it later on,
We're gonna learn more about that.
We can also select data from multiple tables at once
and we're gonna use JOIN for that,
we're going to learn more about that later on.
This is for what we spoke about earlier on in the course,
regarding Relational Data, we'll be using JOINs to do that.
All right, let's go and write some SELECT statements
over in the Database Viewer.
All right, let's go into DB Browser and start looking at
how we can retrieve data using SELECT queries.
Here I'm in the Browse Data tab at the moment and
you can see I've got five rows of data in my users table.
We're gonna use this test data to run our queries against.
If you want to insert some test data into your table,
pause the video now and do that, as well.
Let's go over to execute SEQUEL,
and here we're going to start with a SELECT.
Again, this tells SQLite that we want to
start retrieving data.
The next part of the query must be the columns
that we want to retrieve.
So, for example, first_name and surname.
We don't have to put brackets around these,
just like that is fine.
Then FROM users tells SQLite that this is a table
we want to retrieve data for these columns from.
So if we run this, you can see now down here,
we've got our five rows retrieved.
You can just retrieve data from one column, of course,
and then you just get that column back
for all the rows in the table.
And, if you use the asterisk, or the * sign,
you can retrieve data from all columns.
At the moment, this looks the same as earlier on,
but if you had more columns, then these would all
show up when you use the star.
Like we mentioned earlier, you can filter the data,
and you can select data from multiple tables.
We're going to learn more about that as we move on
through the course.
Thank you for watching this video.
I'll see you in the next one.