LENGTH : to get number of bytes in a stringWe can get number of bytes present against each data can be found by using LENGTH command.
The output is 7
Student TableLet us find out the length of name present in our student table.
We will get a list of id , name and length like this
We can also use length in numeric field like this
Output will be 2 for marks less than 100 and more than 9 ( two digits)
Now let us try to find some blank data using length query
This will display records where Mark is single digit or not entered.
What is the difference between length and char_length ?Length returns string measured in bytes, but char_length returns number of characters. All chars does not occupy single byte particularly Unicode where chars are encoded in two bytes. Here is an example.
Output is here
This article is written by plus2net.com team.