We can get length of the characters present in a string by using char_lenght() function.
The output is 12
We will apply this to our student table
Let us find out the length of name present in our student table.
We will get a list of id , name and length like this
SELECT id, name, char_length(name) as LN FROM `student`
We have seen how to use char_length in SELECT queries. Now let us use them inside WHERE Query
|id|| name|| LN|
|2|| Max Ruin|| 8|
|3 ||Arnold ||6|
Using char_length with WHERE
Now let us try to find some blank data in a numeric field ( mark )
We can combine two columns by using CONCAT() function and then find out the length of the total string.
SELECT id, name FROM `student` WHERE char_length(mark) <=1
SELECT id,CONCAT(name,class) as Name , CHAR_LENGTH(CONCAT(name,class) ) as LN FROM `student`