All right.
It's time for a solution to the relatively painless update exercises.
Let's get going.
The first piece is to change Jackson's name to Jack.
So as I mentioned two videos ago, I like to start by making sure I'm targeting the correct rows before
I do any updating.
So I'll do a select select start from cats.
Select start from cats where and then name equals Jackson.
And let's make sure I get back to the row I'm expecting.
It's simple enough.
There's one Jackson but imagine we were updating multiple rows.
It's a good idea to verify what we're selecting before we actually do the update.
So now I can say update and then we're going to do that set name to be, I believe it was supposed to
be Jack.
Where name equals Jackson.
And there we go.
Let's just do a select star from cats just to see our result.
This is not really a good way to verify your results or that it worked in general if you have a lot
of data.
But if we have like seven rows, we can just quickly find out where's Jack?
But if we had 10,000 rows, that's not not going to work for us.
So we might want to select based off of something else and narrow it down.
Anyway, so that part worked.
Next up, change Ringo's breed to British short hair.
So do the same thing.
Select star from Cat and then I'll do where breed equals and then I'd rather I have that backwards where
name equals Ringo.
We're selecting by name and we're changing Ringo's breed from tabby to British Shorthair so we can keep
that where portion and just delete the select and instead do an update.
Cats set breed to be British Shorthair where name is Ringo.
And again, I'll just do the easy cheating way.
I'll just select everything from cats and we should see Ringo now is a British shorthair.
And then finally update both Maine --, two ages to be 12.
So once again, I'll follow the same process.
Select Star from Cats.
Before I do my update, I'm going to find out how many cats are there Where breed is Maine -- and
there's two.
And that's what I expect.
I want to update both of them to be 12 years old.
Yes, it doesn't make any sense.
One is ten, the other is 11.
There's a bug in our system.
Who knows?
So instead of selecting, I'm going to do an update.
Update cats.
Set age to be 12 where breed is Maine --.
And then once again, let's verify select star from Cats.
And we see those two Maine -- now have an age of 12.
And that's it for our simple exercise.
Hopefully you were able to go through that and not lose your mind out of boredom.
Next up, deletion.