The next function we'll take a look at is pretty quick as well.
It's called Chaar length and what it does is it just tells you how many characters are in a given string
and that's pretty much all there is to it.
So it looks like this char underscore length.
And when we do it on hello world we could count the characters so 1 2 3 4 5 6 for the spaced 7 8 9 10
11 and we get 11.
At least my slides says we get 11.
Let's verify that.
Can't trust those slides.
Whoever made them.
Me.
So you can see we get 11.
So if we changed it and just added a bunch of stuff we won't count it but it says that's 31 characters
long.
OK.
So we could do something like select and let's just print out the author last name this time.
So author Al name comma then will also side by side.
Print the chart the character the character length of the author's last name.
So it might say something like Carver and then next to that one two three four five six characters and
eggers also six characters and so on.
So it's just going to be our author's last name followed by the number of characters and their names
so character char length author L name just like that.
And let's put in as here and we'll just call it we'll just call it length.
Just like that from books will enter and you can see we have this nice little table with our author's
last name and a corresponding length.
So we've got a lot of authors who are six characters long.
The last name six characters long.
And then you know we get Smith who's the shortest and so on.
We'll see later on how he could sort things and order them differently.
But for now we've got them all here.
All right.
So just like before if you feel like you have a grasp of this.
Feel free to move on.
I'm just going to show that we can also combine character length.
So what I would like to do is end up with a result that looks something like this.
Eggers is.
And then six characters long.
So I'd like that for every author that we have.
So if we break it down this is going to be author's last name concatenated with is concatenated with
the character length concatenated with characters long.
So it's going to be kind of a big one.
So let's let's try it out.
We're going to do a select concat and the first thing will concatenate is the author's last name.
So author L name and then we're going to concatenate that with space is space.
So that gives us this right here.
Then inside of that we're going to add char length of author L name.
You can see this is getting kind of long.
Comma is excuse me not is space characters long and are parentheses.
So that's kind of a lot here.
We're concatenating the first thing the author's name and then adding is and then adding the character
length and then adding characters long.
So we're building this sentence one piece at a time and then we also need to specify from books.
OK so let's take a look let's copy this.
Paste it in.
And there we go.
Here he is six characters long.
Carver is six characters.
Steinbeck is nine characters.
Foster Wallace is 14 characters so that's working.
By now you should know he can use as to make this a little prettier.
The only other thing that I'll take a moment to address is that this is kind of ugly.
It's something that I do often to form my sequel meaning my personal sequel not my as well the database
is used one of these formatters.
So there's a couple of them.
I like this one as well dash format dot com and I can paste in my query and just click Format and it
will just format it a little nicer for me.
And it depends on you know when things get really long and have long create tables that will clean things
up nicely for you.
So in this case this is a cleaned up version not that much of a difference to be honest.
But we can replace it anyways.
It's a little easier to read.
All right.
So that's all there is to character like.
That's all there is to char like.