Next up, we have one of the simpler string functions, which is reverse.
Reverse will take whatever string we provide to it and reverse it.
So if I do select reverse the string Hello world, we end up with DeLauro.
Ola It's just the reverse, right?
The casing is still preserved.
It's simply the order that has changed.
I think that's all that there is to it.
It's pretty much it.
Let me show an example or two.
We'll do a select reverse.
And I should have said this earlier, but just like everything with our SQL commands, the different
key words like SELECT or the WHERE clause capitalization doesn't technically matter.
You'll see some people write things like this reverse with a capital R, but not in all caps.
That's also valid.
So let's try reversing chicken nuggets.
And we see Stegen Nick kick.
It's the reverse of chicken nuggets.
OC so catching doesn't matter.
That's all there is to reverse.
Let me show an example from the docks.
So they do select Reverse A, B, C, and we get CBA.
The only exception is if we do this select reverse and then we pass through the explicit value null.
Well, we get no back.
We don't get LUN.
It's just if you pass it, nothing.
The value of nothingness, we get back nothingness.
All right, so let's try doing a simple example.
Let's just select.
How about, well, author f name.
Just start from books, and then let's get the reverse of every author's name.
So that would be select reverse author.
F name from books.
And there we are.
We get every author's reversed.
First name.
Now we can get fancy.
I'll just show one example.
I don't know why we would do this, but let's say I want to turn every person's name.
Like, let's take my name and turn it into a I guess you would call it a palindrome where I'm going
to add on the reverse of my name.
So Colt's becomes Colt to luck.
So backwards and forwards, it's the same.
It's stupid, but we're basically just going to take every name and concatenate it with the reverse.
So why don't we do this over in a script somewhere?
Maybe I'll use DB gates.
I like their formatting a bit better.
We would do something like make some room here.
I'm going to select and then I know that I'm going to contact.
The author first name going forwards with the reverse of the author.
First name.
So reverse author.
F name.
From books.
And let's see if it formats this nicely for me.
Yeah, I think that looks a little bit nicer.
Yeah, not a whole lot.
So I'm concatenating the forward's first name with the reverse.
First name.
Let's see if it works.
I'll just paste it.
And there we are.
We have jumped up a puma badger and Dave evade.
Right, Dave.
Dave.
Simple enough, stupid enough.
That's it for reverse.
Probably not going to be used all that often, but it is a simple one and it's good to know about.