All right.
So the first one is to change Jackson's name to Jack.
So we'll practice what I just talked about running a select before you do the update.
So let's just try selecting Star from Cats.
Where name equals Jackson.
So we get Jackson, but we want to update his name to be Jack.
So now we do our update cats set name equal to Jack.
That's what we want to change it to.
And where do we want to change it?
We want to change it where name is currently Jackson.
Now, it didn't specify that you had to use where name equals Jackson.
You could also say where or where cat ID is seven.
Or where breed is Sphinx because we only have one sphinx right now, so any of those are valid.
Now if we do our select again, we get nothing because there is no cat named Jackson.
If we change it to Jack, we get the same cat whose name is now Jack.
Next up, change Ringo's breed to British Shorthair.
So let's do the same thing where we just do a select.
We're name is Ringo.
You can see that currently breed is short hair, but we want to get more specific British short hair.
So to do that we do an update cats set breed equal to British short hair like that where name equals
Ringo.
And again, you could also do cat ID one or where breed is short hair.
You could identify this cat however you'd like, but let's make sure it worked.
So now if I select where name is Ringo, we see Breed is now British Shorthair.
So the last one update both Maine -- so breed equal Maine -- and make their ages 12.
So let's just take a look at our current setup in our database.
You can see we have these two Maine --, Cindy and double door.
Cindy is ten, double doors, 11.
For whatever reason, we want both of them to be 12.
So let's just select both of them.
First, select star from Cats where breed equals Maine --.
Just like that.
Perfect.
So we are targeting them correctly so we can copy that.
And then we'll do our update.
Cats set age equal to 12.
We don't need quotes where and I'll just paste that in.
And it updates both of them.
So that's really what I was testing here is that you understood that where is not always just going
to return one result, whatever is returned will always be updated.
Which is also important to note that if you leave that where off and I just said update cats set age
12 that would update every cat which we don't want to do, which is why it's always important to select
things first and make sure you know what you're targeting.
Sometimes you might.
There could be reasons you wanted to update everything in a table, like if you were making a big change
or you are migrating something, or you realize that you made a big error early on in your application
and you have every piece of data is wrong somehow, maybe, but most of the time you're being very specific
in the changes you're making.
So just to double check, if we select again, you can see Sindy and Dumbledore are now both 12 and
that's all you needed to do.
Perfect.
Next up, we're diving into delete.