Hello, dear friend.
So in this section, we're going to learn string functions.
Now, Escuela Server provides various escarole string functions which allow us to alter the individual
characters in a string, trim strings, replace strings, convert strings and so on and so forth.
Lots of fun to be had.
So the first function that we're going to learn is the Lenn function.
And this function just returns the length of a string.
So this function takes one parameter.
Now, the parameter must be a string.
So let's jump in SSME and make some examples.
We'll find the length of text with a land function.
It's a learned function except one parameter, and our string will be OK, Academi, 20-20.
And this query will return 16 is the length of this string.
So the next function is left function.
The left function extracts a number of characters from a string starting from the left.
So this function will take two parameters, and it uses its second parameter to decide how many characters
it should return from the left.
And we will use the string, OK, Academy 20/20 as the first parameter and the second parameter will
be three.
And then this query will return the first three characters from the left of the string.
The letters, OK, should be listed, so let's execute it and see.
And there you have it.
Here, the letters have all been listed.
Now, in order to get the academy keywords, the second parameter should be 11 because there are 11
characters, because, of course, the spaces are also counted.
Trim function.
And in some cases, we may need to remove spaces from a string.
For instance, bases can cause problems while comparing two strings, and before we start to compare,
we've got to remove the spaces from the string, right.
So the trem function removes leading and trailing spaces from a string and guess what, it takes a string
as a parameter.
So we're going to use the string, OK, academy as the string, and we will add some spaces to the end
of the string.
Then the trim function will remove the leading and trailing spaces from the string.
So let's execute the query.
And here is the result.
All the spaces have been removed from the string.
Now, there are two functions that we can use in order to remove spaces from a string.
The first one is El Trem function.
The EL function is used to remove the leading blanks from a string.
Second function is the art trim function.
The Archim function is used to remove the trailing blanks from a string.
Lower function.
Now, the lower function is used to convert the given expression or text into a lowercase.
So this function accepts only a string parameter.
The parameter of the lower function will be OK, Academi 2020 with capital letters.
And if we execute the query, we will see that all the letters have been converted into lowercase.
So life wouldn't be complete without the upper function.
The upper function is used to convert the given expression or text into uppercase.
And this function accepts only a string as a parameter.
The perimeter of the upper function will be OK, Academy 2020, again in lower case.
And then if we execute the query, we will see that all the letters have been converted into uppercase.
All right, so let's retrieve the first name and last name from the person table.
And here are the first names and the last names.
Now, we may need to convert a text to uppercase while retrieving from a table.
So let's convert both first name and last name into uppercase.
And that way, we should use the other key word for each column.
So if you just executed and great, so all the first names and last names have been converted into uppercase.
The reverse function.
So the reverse function is used to reverse a string and return the result of that.
So this function accepts only one string as a parameter.
So let's reverse the string, OK, Academy 20-20.
We should specify that string as a parameter of the reverse function.
And that's it.
He's ready.
So if we execute the query, we will see that this string has been reversed.
Would you believe me if I told you that there's something called the replace function?
The replace function is used to replace all occurrences of a substring within a string with a new substring.
And this function accepts three parameters.
So the first parameter is this string, the second parameter is a part of the string that we want to
change.
And the last parameter is a part of the string that we want to be the replacement string.
So that's a new part.
So in this example, the string will be OK, Academy 2020 as the first parameter.
And the day 2020 is part of this string and it will be the second parameter.
Now, this is the part that we're going to want to change.
The date 2021 will be the third parameter with the replace function.
And this value will be the replacement with in other words, this will replace the second parameter,
right?
So this is what our query looks like when it's ready to be executed.
And then if we execute the query, we will see that the second parameter has been changed into the third
parameter.
Substring function.
So the substring function is used to extract some characters from a string, so the substring function
accepts three parameters.
The first parameter is the string, the second parameter is the start position, and then the last parameter
is the length of the characters to extract.
And it must be a positive number.
So we're going to use OK, Academy 2020 again as a as the first parameter string.
And the start position will be five and then this will be the second parameter.
So the length of the characters to extract will be 12, and then that makes that the third parameter
of the substring function.
So when we execute the query, it will return a string from five is a start position, and then after
counting five characters from the beginning of the first parameter, the start point will then be at
the beginning of the academy keyword.
Then it will count 12 characters and return the string.
And the length of the Academy 2020 is well.
So Academy 2020 is returned.
So what do you think of that?
In this section, we've learned string functions, now the following section, we're going to learn
the math functions.
You think it's all been leading up to this?
Well, you may be right, so we'll see you there.