Next, we're going to talk about the where clause.
So where is a special keyword in SQL or in my SQL, but also just SQL in general that allows us to narrow
down the rows that we're working with.
So in our case, we're talking about selecting rows and currently we're selecting every single row.
We have seven cats, we get seven rows back, even if we specify we only want name and breed.
That's just the columns we're getting all the rows, but using where we can narrow things down.
And I want to be clear here, where is not limited to working with select, we will be using where to
make updates or to delete rows as well.
So it's kind of a jack of all trades, but in our case we're starting with select so we can use where
to narrow things down.
For example, to find all the cats select star from cats where age is exactly equal to four.
So there's different ways we can select using where it's not just equality, but that's what we're going
to start with.
Age equals four.
So let's try it.
Select star from cats where age equals four and we see two rows.
Ringo And Egg, the cat egg, who is four, They're both four years old, so we're still getting all
the rows.
But if I wanted to, I could say I only want name and age from cats where age is four.
And there we go.
Name and age, same rows, but just two columns.
Additionally, I see some students get confused and think that we have to select age if we are trying
to use wear with age, but we don't.
I could only get the names from cats where age equals four.
This is going to happen first.
This kind of happens second.
So the first thing that will happen is, All right, we're going to Cat's table, I'm SQL, my SQL,
and we see that we're looking for all rows that have age set to four.
We found two rows.
What does the user want back?
The user only wants name, so we give them name so you don't have to actually select a column to work
with it.
Over here, they're completely independent, so this just gives me the names of the cats who are exactly
four.
But there's more that we could do.
We could do a match based off of a piece of text.
If that's what we're trying to do.
We have to use quotes, of course, to match a text or a piece of text.
Let's do select star from Cat where name equals egg.
And you might think I have to capitalize it exactly the same, which sometimes you do.
There's different ways of of setting this up.
But for now we don't.
If I just do name equals egg, I am matching it.
It's uppercase.
E That's great.
But if I did lowercase E here, it still works.
Even if I did lowercase e, uppercase g's, we still are matching It is case insensitive in this example,
but there are ways of enforcing that case sensitivity.
But a lot of the time you don't really want that.
It can help you out a bit more if you're just trying to find something and you're not sure of how it's
capitalized.
Although I probably wouldn't spell egg this way with two uppercase G's so we can select based off of
a numeric column, or it's exactly for a var car or a piece of text where it's exactly some string like
egg and there's some fancier operations we're going to learn in a little bit.
But up next, it's time for you to get some practice with some rapid fire exercises.
That's the next video.