1 00:00:00,270 --> 00:00:00,840 All right. 2 00:00:00,840 --> 00:00:05,040 So the first one is to change Jackson's name to Jack. 3 00:00:05,520 --> 00:00:10,260 So we'll practice what I just talked about running a select before you do the update. 4 00:00:10,260 --> 00:00:14,220 So let's just try selecting Star from Cats. 5 00:00:15,000 --> 00:00:18,810 Where name equals Jackson. 6 00:00:21,790 --> 00:00:25,600 So we get Jackson, but we want to update his name to be Jack. 7 00:00:25,600 --> 00:00:34,750 So now we do our update cats set name equal to Jack. 8 00:00:35,350 --> 00:00:37,120 That's what we want to change it to. 9 00:00:37,360 --> 00:00:39,340 And where do we want to change it? 10 00:00:39,370 --> 00:00:43,270 We want to change it where name is currently Jackson. 11 00:00:43,780 --> 00:00:47,390 Now, it didn't specify that you had to use where name equals Jackson. 12 00:00:47,410 --> 00:00:50,950 You could also say where or where cat ID is seven. 13 00:00:51,160 --> 00:00:56,980 Or where breed is Sphinx because we only have one sphinx right now, so any of those are valid. 14 00:00:58,240 --> 00:01:03,550 Now if we do our select again, we get nothing because there is no cat named Jackson. 15 00:01:04,540 --> 00:01:08,530 If we change it to Jack, we get the same cat whose name is now Jack. 16 00:01:10,390 --> 00:01:14,710 Next up, change Ringo's breed to British Shorthair. 17 00:01:15,580 --> 00:01:18,270 So let's do the same thing where we just do a select. 18 00:01:18,280 --> 00:01:19,930 We're name is Ringo. 19 00:01:21,100 --> 00:01:27,670 You can see that currently breed is short hair, but we want to get more specific British short hair. 20 00:01:28,030 --> 00:01:43,990 So to do that we do an update cats set breed equal to British short hair like that where name equals 21 00:01:44,860 --> 00:01:45,490 Ringo. 22 00:01:45,820 --> 00:01:50,650 And again, you could also do cat ID one or where breed is short hair. 23 00:01:50,800 --> 00:01:56,730 You could identify this cat however you'd like, but let's make sure it worked. 24 00:01:56,740 --> 00:02:02,620 So now if I select where name is Ringo, we see Breed is now British Shorthair. 25 00:02:04,490 --> 00:02:11,510 So the last one update both Maine -- so breed equal Maine -- and make their ages 12. 26 00:02:11,780 --> 00:02:15,050 So let's just take a look at our current setup in our database. 27 00:02:17,180 --> 00:02:20,570 You can see we have these two Maine --, Cindy and double door. 28 00:02:20,600 --> 00:02:23,000 Cindy is ten, double doors, 11. 29 00:02:23,120 --> 00:02:26,060 For whatever reason, we want both of them to be 12. 30 00:02:26,630 --> 00:02:28,250 So let's just select both of them. 31 00:02:28,250 --> 00:02:36,950 First, select star from Cats where breed equals Maine --. 32 00:02:37,670 --> 00:02:38,690 Just like that. 33 00:02:39,620 --> 00:02:40,310 Perfect. 34 00:02:40,580 --> 00:02:44,570 So we are targeting them correctly so we can copy that. 35 00:02:45,080 --> 00:02:46,880 And then we'll do our update. 36 00:02:47,750 --> 00:02:52,330 Cats set age equal to 12. 37 00:02:52,340 --> 00:02:56,660 We don't need quotes where and I'll just paste that in. 38 00:02:58,750 --> 00:03:00,130 And it updates both of them. 39 00:03:00,130 --> 00:03:05,650 So that's really what I was testing here is that you understood that where is not always just going 40 00:03:05,650 --> 00:03:09,760 to return one result, whatever is returned will always be updated. 41 00:03:10,000 --> 00:03:16,570 Which is also important to note that if you leave that where off and I just said update cats set age 42 00:03:16,570 --> 00:03:23,050 12 that would update every cat which we don't want to do, which is why it's always important to select 43 00:03:23,050 --> 00:03:25,510 things first and make sure you know what you're targeting. 44 00:03:25,510 --> 00:03:27,310 Sometimes you might. 45 00:03:27,310 --> 00:03:32,350 There could be reasons you wanted to update everything in a table, like if you were making a big change 46 00:03:32,350 --> 00:03:38,770 or you are migrating something, or you realize that you made a big error early on in your application 47 00:03:38,770 --> 00:03:45,160 and you have every piece of data is wrong somehow, maybe, but most of the time you're being very specific 48 00:03:45,160 --> 00:03:46,420 in the changes you're making. 49 00:03:47,230 --> 00:03:53,680 So just to double check, if we select again, you can see Sindy and Dumbledore are now both 12 and 50 00:03:53,680 --> 00:03:54,790 that's all you needed to do. 51 00:03:55,240 --> 00:03:55,860 Perfect. 52 00:03:55,870 --> 00:03:58,090 Next up, we're diving into delete.