Next up, we have care length or cha length.
It's going to tell us the number of characters in a given string.
So if I did something like Car cha length Hello World, it's going to tell me one, two, three, four,
five, six, seven, eight, nine, ten, 11.
And that's what the slide says.
We can trust it or we can just try it ourselves.
Select cha length from and then let's just do hey, exclamation point and we get four.
Now, something that can be confusing is that there's another function, a string function called No,
not left.
Length and length will return the length of a string as well, measured in bytes.
So it might appear the same if I did just regular length of hey, we get four.
And that's because each character here can be stored in a single byte.
But that's not the case with something like this.
This is, I believe, from Chinese characters for Dolphin, and it looks like it's two characters,
but those characters take up more, more storage essentially.
So it's actually six bytes.
And if I really wanted to know the character length, I would use char length.
And it's exactly two characters.
So there is a difference.
Not always, but there is an important distinction between those two functions.
Even if a lot of the time with simple characters, we'll get the same result.
That is not always the case.
Length is going to return a value in bytes.
Char length tells us the number of characters doesn't care about bytes, just characters.
So let's let's find out the character length of the titles in our database, select char length title
from books.
And let's also put well, let's put the book title there as well.
So let's do comma title from books and the clear longest one, just looking at this is what we talk
about when we talk about love stories, but there's still some other long ones, right?
A heartbreaking work of Staggering Genius, The Amazing Adventures of Kavalier and Clay, where I'm
calling from Selected Stories doesn't really matter, right?
The point is that we can find the number of characters in some column for every row.
So in this case it was title that we're working with.
And just like any of these other functions we've been working with, we can alias this.
I could call this as Len if I wanted it to be Len That's the length of the title, or I could call it
title length or title chars or something like that.
But I think that's enough.
It's a simple enough one chart length again gives us the characters in whatever we provide.
Length gives us the bytes.