WEBVTT

00:00.310 --> 00:00.770
All right.

00:00.990 --> 00:05.170
So the first one is to change Jackson's name to Jack.

00:05.670 --> 00:10.280
So we'll practice what I just talked about running select before you do the update.

00:10.440 --> 00:21.390
So let's just try selecting star from cats where name equals Jackson.

00:21.450 --> 00:25.580
OK so we get Jackson but we want to update his name to be Jack.

00:25.740 --> 00:30.360
So now we do our update cats.

00:31.170 --> 00:35.430
Set name equal to Jack.

00:35.450 --> 00:37.220
That's what we want to change it to.

00:37.560 --> 00:39.510
And where do we want to change it.

00:39.510 --> 00:43.520
We're going to change it where name is currently Jackson.

00:43.810 --> 00:47.520
Now I didn't specify that you had to use wear name ECOs Jackson.

00:47.520 --> 00:54.090
You could also say where everywhere everywhere ID is 7 or where breed is Fink's because we only have

00:54.090 --> 00:55.410
one Spinx right now.

00:55.410 --> 00:57.530
So any of those are valid.

00:58.320 --> 01:04.390
Now if we do or select again we get nothing because there is no cat named Jackson.

01:04.540 --> 01:10.330
If we change it to Jack we get the same cat whose name is now Jack.

01:10.470 --> 01:15.160
Next up change Ringo's breed to British short hair.

01:15.690 --> 01:18.260
So let's do the same thing where we just do a select.

01:18.480 --> 01:21.150
Her name is Ringo.

01:21.150 --> 01:28.340
You can see that currently breed is short hair but we want to get more specific British short hair so

01:28.350 --> 01:30.800
to do that we do an update.

01:30.900 --> 01:45.700
Cats set breed equal to British short hair like that where a name equals Ringo.

01:45.890 --> 01:53.820
And again you can also do cat ID one or where breed is shorthair you could identify this cat however

01:53.820 --> 01:56.790
you like but let's make sure it worked.

01:56.790 --> 02:04.520
So now if I select where name is Ringo we see Breede is now British short hair.

02:04.590 --> 02:11.880
So the last one update both Maine Coons so breed equal Maine Coon and make their ages 12.

02:11.940 --> 02:18.920
So let's just take a look at our current set up in our database can see we have these two main COONTS

02:19.180 --> 02:20.730
Cindy undoubled door.

02:20.760 --> 02:24.360
Cindy is 10 Dumbledores 11 for whatever reason.

02:24.420 --> 02:26.420
We want both of them to be 12.

02:26.790 --> 02:29.110
So let's just select both of them first.

02:29.350 --> 02:39.260
Select star from cats where greed equals man you're just like that.

02:39.630 --> 02:40.660
Perfect.

02:40.710 --> 02:47.290
So we are we are targeting them correctly so we can copy that and then we'll do our update.

02:47.760 --> 02:59.460
Cats set age equal to 12 we don't need quotes where I'm just at and it updates.

02:59.470 --> 03:00.110
Both of them.

03:00.130 --> 03:05.590
So that's really what I was testing here is that you understood that where is not always just going

03:05.590 --> 03:07.010
to return one result.

03:07.270 --> 03:09.900
Whatever is returned will always be updated.

03:10.150 --> 03:17.020
Which is also important to note that if you leave that wear off and I just said Update cat set age 12

03:17.860 --> 03:23.320
that would update every cat which we don't want to do which is why it's always important to select things

03:23.320 --> 03:25.600
first and make sure you know what you're targeting.

03:25.620 --> 03:30.750
Sometimes you might there could be reason to be wanting to update everything in a table like if you

03:30.750 --> 03:37.540
are making a big change or you are migrating something or you realize that you made a big error early

03:37.540 --> 03:41.610
on in your application and you have every piece of data is wrong somehow.

03:41.620 --> 03:46.760
Maybe but most of the time you're being very specific in the changes you're making.

03:47.380 --> 03:49.980
So just to double check we select again.

03:50.080 --> 03:53.220
You can see Cindy and double door and now both 12.

03:53.650 --> 03:55.300
That's all you needed to do.

03:55.300 --> 03:55.960
Perfect.

03:55.960 --> 03:57.820
Next up we're diving into delete.
