This is the solution Video for the Rapid Fire Exercises.
The first query I'd like you to write prints out the cat IDs for all rows.
So it's as simple as select cat ID from cats, no wear cloths.
We just want all of them and we see one, two, three, four, five, six, seven.
Not all that useful.
Next up, we need to work with the name and the breed for all rows.
It's all seven rows so we don't have a wear clause, but we are going to narrow down what we select.
It's not going to be star, it's name and then breed.
And I guess to be specific, that's the order we want.
If I had done Breed and then name, they would be reversed.
Even if it's the same information, it wouldn't be quite as correct.
So name, comma, breed from cats, all of them.
And we see Ringo down to Jackson Ock.
The third piece, write the sequel that selects the Tabby Cats.
So we'll start by selecting Star from Cats.
And then where breed is equal to tabby, So breed equals tabby.
So that gives us two rows, Ringo and Misty.
But we can't stop there because I'm only supposed to get name and age, so I'm going to narrow this
down and not select everything.
I'm going to select name, comma, age from cats where breed is tabby.
So give me the names and the ages of our tabby cats.
Ringo four, Misty 13 That looks correct.
And then finally, somewhat trickier, write a query to select the cat IDs and the age from the cats
that have the same cat ID and age.
So if I select them all we see age is set to four.
Here.
I had a cat.
It is four cat IDs, seven ages seven.
So what we can do is select star from cats where and then we can do this instead of saying cat ID is
four or cat ID is seven.
I can actually say cat ID equals H and my SQL can figure that out.
It can say for each row, Is that Rowe's cat ID the same as its age?
If that's the case, then we are going to select that.
We will include that in our data that is printed out.
However, right now I'm doing cat ID, name, breed and age.
Technically I'm only supposed to print out cat ID and age, so let's do that again.
But change this, narrow it to B, cat ID comma H, and now we see four, four, seven, seven.
Not very useful, but it is something that we can do.
And of course all of these queries could be written in a file.
I should just show that here from workbench or DB gate.
Let's do workbench.
I will run this here.
So I'll click this little lightning bolts and we see four, four, seven, seven.
There we go.
So that's our exercise.
We've got a lot more to cover.