Here's a quick solution to the delete exercise.
First up, delete all four year old cats.
So like I said, I like to make sure I can select those first select star from cats where age equals
exactly four.
And it looks like there's just one of them ages four.
Ringo Great.
So instead of doing a select star, I'm going to do a delete from cats where age equals four.
And I should also get some confirmation, right?
I see one row affected.
That is a very it's an understatement.
It wasn't just affected, it was removed.
If I do a select star from cats, we'll see.
Ringo is just gone entirely now.
And if I tried to rerun that query from earlier, a couple of lines to go select Star from Cats where
age is four, we get an empty set.
We have no resulting rows.
Next, delete the cats whose age is the same as their cat ID.
So once again, I like to start with a select select start from cats.
And then where age is equal to cat ID.
We saw this when we talked about selecting with where we can do things like two different column names
and compare them.
Now there's only one matching cat.
So we see Jack cat idea seven age of seven.
Well, we're going to delete you, Cat.
I mean, Jack, technically, also cat delete from cats where age equals cat ID If I try to run my select
again, it's gone.
Select star from cats.
We're now down to four cats.
I deleted Egg in the intro to deletion video just in case you're wondering how we went from 7 to 4.
Well, now we're going to go from four to knockouts, delete all of them.
And this one, simple enough.
You just want to be careful with this.
If I do delete from cats and nothing else, they're all gone.
So be careful if you have data you care about.
But we don't have anything we care about.
I'm sorry, cats.
We've shut down the shelter and euthanized all of you.
Goodbye.
Now we look at cats.
Nothing in there.
Och, that's it.
Next up, we've got a much bigger exercise to put it all together.