The next function we'll take a look at is pretty quick as well.
It's called char 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 one, two, three, four, five, six for the space seven eight, nine, ten, 11 and we get 11 at
least my slide says we get 11.
Let's verify that.
I 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.
So we could do something like Select and let's just print out the author last name this time.
So Author L name comma.
Then we'll also side by side print 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 in their name.
So character, char length, author, l name just like that.
And let's put an as here and we'll just call it we'll just call it length just like that from books
we'll hit enter and you can see we get this nice little table with our author's last name and the corresponding
length.
So we've got a lot of authors who are six characters long or their last name, six characters long,
and then we get Smith, who's the shortest, and so on.
We'll see later on how we 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 kin cat and the first thing we'll concatenate is the author's last name.
So author LL 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 our 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.
Okay, so let's take a look.
Let's copy this, paste it in, and there we go.
Lahiri 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 we 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 at my school, meaning my personal school, not my SQL.
The database is used one of these for matters.
So there's a couple of them.
I like this one SQL dash format.
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 when things get really long.
When we have long create tables, it 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 length.
That's all there is to char length.