1 00:00:00,060 --> 00:00:02,130 So let's talk about solutions to these. 2 00:00:03,120 --> 00:00:05,880 The first one to delete all four year old cats. 3 00:00:06,000 --> 00:00:09,540 All we need to do is start off and you don't have to do this. 4 00:00:09,540 --> 00:00:12,540 But I like to start off by making sure we're selecting things correctly. 5 00:00:12,540 --> 00:00:18,780 So select start from cats where age equals four, we get Ringo. 6 00:00:19,290 --> 00:00:21,210 Then I just like to copy this. 7 00:00:23,660 --> 00:00:27,820 And do a delete from cats. 8 00:00:29,120 --> 00:00:33,110 And of course I forgot to add a space but delete from cats for ages four. 9 00:00:34,550 --> 00:00:39,530 Now if we do a let's do our first select, we should see nothing. 10 00:00:39,530 --> 00:00:41,600 And if we do a select star. 11 00:00:44,030 --> 00:00:47,240 We should see that we're now missing number one. 12 00:00:47,240 --> 00:00:49,430 Who was Ringo by Ringo. 13 00:00:50,840 --> 00:00:55,970 Next up, delete cats whose age is the same as their cat ID. 14 00:00:56,780 --> 00:01:01,730 So this one involved something slightly different, like I mentioned, where we're not just checking 15 00:01:01,730 --> 00:01:06,860 for a specific piece of data like breed equals Maine -- or age equals 12. 16 00:01:06,860 --> 00:01:09,860 But we're checking where cat ID equals age. 17 00:01:10,160 --> 00:01:20,840 So we'll do a select first select star from cats where cat ID equals H. 18 00:01:20,840 --> 00:01:26,210 Or you could do age equals cat ID and we get jack cat ID is seven age seven. 19 00:01:26,210 --> 00:01:26,750 Great. 20 00:01:27,200 --> 00:01:29,360 So then we'll just copy this. 21 00:01:33,100 --> 00:01:37,660 And do our delete from cats where cat id equals age. 22 00:01:38,170 --> 00:01:39,520 It says one row affected. 23 00:01:39,520 --> 00:01:41,620 If we try and select it again, it's gone. 24 00:01:41,650 --> 00:01:46,120 And if we do a select star now, we're also missing Jack. 25 00:01:46,220 --> 00:01:51,790 You can see we just have two, three, five and six, which leads us to our final example. 26 00:01:52,420 --> 00:01:53,680 Delete all cats. 27 00:01:54,280 --> 00:01:56,830 So this one is pretty straightforward. 28 00:01:57,790 --> 00:02:03,810 If we try to do the equivalent select, it would just be select star from cats with no ensuing where 29 00:02:03,820 --> 00:02:04,480 clause. 30 00:02:05,610 --> 00:02:06,600 Just like that. 31 00:02:06,960 --> 00:02:12,390 So to delete all of those, well, it's just delete from cats. 32 00:02:13,020 --> 00:02:17,580 All of our cats are being released at once into a land of rainbows and joy. 33 00:02:17,610 --> 00:02:18,510 We hit enter here. 34 00:02:18,510 --> 00:02:21,210 They're definitely 100% not dying. 35 00:02:21,450 --> 00:02:23,670 Nothing bad will ever happen to them. 36 00:02:23,700 --> 00:02:24,480 Here we go. 37 00:02:25,790 --> 00:02:31,700 Ford Rose affected select star from Cats The moment of truth. 38 00:02:32,660 --> 00:02:34,790 And they're all gone and not dead. 39 00:02:35,370 --> 00:02:41,090 Okay, so we've now covered the C and the R and the U and the D and crud that spells crud, which means 40 00:02:41,090 --> 00:02:41,840 that we're done with this. 41 00:02:41,870 --> 00:02:44,720 Next up, we'll get some practice putting it all together.