1 00:00:00,090 --> 00:00:04,350 Next up, we have one of the simpler string functions, which is reverse. 2 00:00:04,380 --> 00:00:08,870 Reverse will take whatever string we provide to it and reverse it. 3 00:00:08,880 --> 00:00:14,430 So if I do select reverse the string Hello world, we end up with DeLauro. 4 00:00:14,580 --> 00:00:16,890 Ola It's just the reverse, right? 5 00:00:16,890 --> 00:00:18,360 The casing is still preserved. 6 00:00:18,360 --> 00:00:20,640 It's simply the order that has changed. 7 00:00:20,940 --> 00:00:22,470 I think that's all that there is to it. 8 00:00:22,500 --> 00:00:23,370 It's pretty much it. 9 00:00:23,400 --> 00:00:24,840 Let me show an example or two. 10 00:00:25,110 --> 00:00:27,510 We'll do a select reverse. 11 00:00:27,510 --> 00:00:32,970 And I should have said this earlier, but just like everything with our SQL commands, the different 12 00:00:32,970 --> 00:00:41,700 key words like SELECT or the WHERE clause capitalization doesn't technically matter. 13 00:00:41,730 --> 00:00:48,540 You'll see some people write things like this reverse with a capital R, but not in all caps. 14 00:00:48,540 --> 00:00:49,800 That's also valid. 15 00:00:50,100 --> 00:00:53,610 So let's try reversing chicken nuggets. 16 00:00:55,310 --> 00:00:59,200 And we see Stegen Nick kick. 17 00:00:59,660 --> 00:01:01,970 It's the reverse of chicken nuggets. 18 00:01:02,410 --> 00:01:04,580 OC so catching doesn't matter. 19 00:01:04,580 --> 00:01:06,140 That's all there is to reverse. 20 00:01:06,170 --> 00:01:08,510 Let me show an example from the docks. 21 00:01:08,510 --> 00:01:13,040 So they do select Reverse A, B, C, and we get CBA. 22 00:01:13,190 --> 00:01:20,270 The only exception is if we do this select reverse and then we pass through the explicit value null. 23 00:01:20,390 --> 00:01:22,190 Well, we get no back. 24 00:01:22,340 --> 00:01:23,690 We don't get LUN. 25 00:01:24,410 --> 00:01:26,470 It's just if you pass it, nothing. 26 00:01:26,480 --> 00:01:29,660 The value of nothingness, we get back nothingness. 27 00:01:30,620 --> 00:01:33,260 All right, so let's try doing a simple example. 28 00:01:33,440 --> 00:01:34,610 Let's just select. 29 00:01:34,610 --> 00:01:37,910 How about, well, author f name. 30 00:01:38,360 --> 00:01:43,640 Just start from books, and then let's get the reverse of every author's name. 31 00:01:43,650 --> 00:01:47,660 So that would be select reverse author. 32 00:01:48,720 --> 00:01:52,110 F name from books. 33 00:01:52,770 --> 00:01:53,760 And there we are. 34 00:01:53,790 --> 00:01:55,860 We get every author's reversed. 35 00:01:55,860 --> 00:01:56,730 First name. 36 00:01:57,450 --> 00:01:59,030 Now we can get fancy. 37 00:01:59,040 --> 00:02:00,410 I'll just show one example. 38 00:02:00,420 --> 00:02:05,040 I don't know why we would do this, but let's say I want to turn every person's name. 39 00:02:05,040 --> 00:02:11,730 Like, let's take my name and turn it into a I guess you would call it a palindrome where I'm going 40 00:02:11,730 --> 00:02:15,750 to add on the reverse of my name. 41 00:02:15,750 --> 00:02:18,450 So Colt's becomes Colt to luck. 42 00:02:18,450 --> 00:02:21,210 So backwards and forwards, it's the same. 43 00:02:21,210 --> 00:02:27,360 It's stupid, but we're basically just going to take every name and concatenate it with the reverse. 44 00:02:27,360 --> 00:02:30,000 So why don't we do this over in a script somewhere? 45 00:02:30,000 --> 00:02:31,570 Maybe I'll use DB gates. 46 00:02:31,650 --> 00:02:33,330 I like their formatting a bit better. 47 00:02:33,840 --> 00:02:37,320 We would do something like make some room here. 48 00:02:38,860 --> 00:02:43,570 I'm going to select and then I know that I'm going to contact. 49 00:02:44,720 --> 00:02:50,300 The author first name going forwards with the reverse of the author. 50 00:02:50,300 --> 00:02:51,110 First name. 51 00:02:51,110 --> 00:02:53,870 So reverse author. 52 00:02:54,080 --> 00:02:54,830 F name. 53 00:02:55,640 --> 00:02:57,320 From books. 54 00:02:57,650 --> 00:03:00,620 And let's see if it formats this nicely for me. 55 00:03:00,800 --> 00:03:03,110 Yeah, I think that looks a little bit nicer. 56 00:03:03,260 --> 00:03:04,670 Yeah, not a whole lot. 57 00:03:05,180 --> 00:03:09,710 So I'm concatenating the forward's first name with the reverse. 58 00:03:09,710 --> 00:03:10,600 First name. 59 00:03:10,610 --> 00:03:11,450 Let's see if it works. 60 00:03:11,450 --> 00:03:12,590 I'll just paste it. 61 00:03:13,340 --> 00:03:14,270 And there we are. 62 00:03:14,270 --> 00:03:20,500 We have jumped up a puma badger and Dave evade. 63 00:03:20,510 --> 00:03:21,590 Right, Dave. 64 00:03:21,590 --> 00:03:22,240 Dave. 65 00:03:22,550 --> 00:03:24,160 Simple enough, stupid enough. 66 00:03:24,170 --> 00:03:25,670 That's it for reverse. 67 00:03:25,700 --> 00:03:30,680 Probably not going to be used all that often, but it is a simple one and it's good to know about.