Now that we've got some data in our database how do we access this data.
The standard way to do it is to use structured query language.
S.
Well we can write statements in ask you l that will allow us to perform various operations on the data
in the database from selecting data inserting new records are updating existing ones.
Let's begin with selecting some data for that we use the select statement.
First we start with the word select followed by the names of the columns we want then from followed
by the table name.
If you want to select all the columns then you can say select asterisk are select star.
Instead we end the ESC U L statement with a semicolon.
Note that ESC U L is case insensitive.
But it's common practice to write kumail key words like select and from using uppercase and names of
tables and columns.
In lower case using the select statement is commonly referred to as an S Q L query.
Let's try this out.
Here we have our articles table and I have added several rijkaard to it.
So we've got some data to play with.
If we click on the esky well Tab we can enter some ESC U L statement.
Let's start by selecting all the fields from our article table.
If we run this by clicking the go button we get all the records.
This is known as the result set.
Let's change it to just select the title.
And when we run this now in our resultset we just have the titles.
Instead of selecting the entire table we can use the where clause to filter the Ricardos passing in
a condition that records have to match.
Let's try selecting the rijkaard where the idea is to note the comparison operator is different to the
one we used in p p.
Remember in P.
P to compare two values we used to equal signs in s q L we use just one like this.
When we run this the resultset contains just one record.
This is why we added a primary key using this where clause on the idees column like this means that
we can select one individual record from the database.
It's also possible to have an empty resultset for example if we use a where clause that doesn't match
any records.
We don't get any data.
We can also compare columns that contain strings.
If we look at the data in our table we can see that there are two records with the same title.
If we query the database for all records that contain this title using this where clause then when we
run this we get those two roles.
Note that if we're comparing to a string we need to close it in single quotes like this.
Incidentally this is where the database colation that we set when we created the database is used when
strings are being compared.
In addition to equals there are other comparison operators we can use just like in P H.
P
For example we can change the query we just wrote to get all the roles where the title doesn't equal
this by using the not equal operator.
Like that.
We can also combined where clase is using and and are just like we can combine comparison operators
in P HP
so we can add aware class to this query to get all the roles where the title is this are.
The title is this.
One more thing I want to mention is whitespace.
You well like P HP and H to email doesn't care about whitespace so you can have the query all on one
line like this.
Or you could put it on different lines like this.
It's quite common to do this with more complex queries as they're easier to understand.