1 00:00:00,150 --> 00:00:03,820 This is the solution Video for the Rapid Fire Exercises. 2 00:00:03,840 --> 00:00:09,630 The first query I'd like you to write prints out the cat IDs for all rows. 3 00:00:10,290 --> 00:00:16,560 So it's as simple as select cat ID from cats, no wear cloths. 4 00:00:16,560 --> 00:00:20,250 We just want all of them and we see one, two, three, four, five, six, seven. 5 00:00:20,250 --> 00:00:21,510 Not all that useful. 6 00:00:22,050 --> 00:00:25,800 Next up, we need to work with the name and the breed for all rows. 7 00:00:25,800 --> 00:00:31,110 It's all seven rows so we don't have a wear clause, but we are going to narrow down what we select. 8 00:00:31,110 --> 00:00:34,920 It's not going to be star, it's name and then breed. 9 00:00:34,920 --> 00:00:38,760 And I guess to be specific, that's the order we want. 10 00:00:38,760 --> 00:00:41,940 If I had done Breed and then name, they would be reversed. 11 00:00:41,940 --> 00:00:45,630 Even if it's the same information, it wouldn't be quite as correct. 12 00:00:45,630 --> 00:00:48,690 So name, comma, breed from cats, all of them. 13 00:00:48,690 --> 00:00:51,650 And we see Ringo down to Jackson Ock. 14 00:00:52,380 --> 00:00:56,270 The third piece, write the sequel that selects the Tabby Cats. 15 00:00:56,280 --> 00:01:00,120 So we'll start by selecting Star from Cats. 16 00:01:00,120 --> 00:01:08,100 And then where breed is equal to tabby, So breed equals tabby. 17 00:01:09,120 --> 00:01:11,880 So that gives us two rows, Ringo and Misty. 18 00:01:12,090 --> 00:01:17,010 But we can't stop there because I'm only supposed to get name and age, so I'm going to narrow this 19 00:01:17,010 --> 00:01:19,560 down and not select everything. 20 00:01:19,560 --> 00:01:25,140 I'm going to select name, comma, age from cats where breed is tabby. 21 00:01:25,140 --> 00:01:27,810 So give me the names and the ages of our tabby cats. 22 00:01:27,810 --> 00:01:31,230 Ringo four, Misty 13 That looks correct. 23 00:01:31,410 --> 00:01:38,160 And then finally, somewhat trickier, write a query to select the cat IDs and the age from the cats 24 00:01:38,160 --> 00:01:40,980 that have the same cat ID and age. 25 00:01:41,160 --> 00:01:44,520 So if I select them all we see age is set to four. 26 00:01:44,520 --> 00:01:45,030 Here. 27 00:01:45,390 --> 00:01:46,230 I had a cat. 28 00:01:46,230 --> 00:01:49,830 It is four cat IDs, seven ages seven. 29 00:01:50,220 --> 00:01:57,810 So what we can do is select star from cats where and then we can do this instead of saying cat ID is 30 00:01:57,810 --> 00:01:59,370 four or cat ID is seven. 31 00:01:59,370 --> 00:02:05,040 I can actually say cat ID equals H and my SQL can figure that out. 32 00:02:05,040 --> 00:02:09,750 It can say for each row, Is that Rowe's cat ID the same as its age? 33 00:02:09,750 --> 00:02:12,900 If that's the case, then we are going to select that. 34 00:02:12,900 --> 00:02:16,050 We will include that in our data that is printed out. 35 00:02:16,060 --> 00:02:19,770 However, right now I'm doing cat ID, name, breed and age. 36 00:02:19,800 --> 00:02:25,050 Technically I'm only supposed to print out cat ID and age, so let's do that again. 37 00:02:25,050 --> 00:02:31,980 But change this, narrow it to B, cat ID comma H, and now we see four, four, seven, seven. 38 00:02:31,980 --> 00:02:35,190 Not very useful, but it is something that we can do. 39 00:02:35,190 --> 00:02:38,940 And of course all of these queries could be written in a file. 40 00:02:39,450 --> 00:02:44,160 I should just show that here from workbench or DB gate. 41 00:02:44,190 --> 00:02:45,330 Let's do workbench. 42 00:02:45,570 --> 00:02:46,950 I will run this here. 43 00:02:46,950 --> 00:02:51,270 So I'll click this little lightning bolts and we see four, four, seven, seven. 44 00:02:51,270 --> 00:02:52,050 There we go. 45 00:02:52,890 --> 00:02:53,910 So that's our exercise. 46 00:02:53,910 --> 00:02:54,990 We've got a lot more to cover.