CHAR_LENGTH('string');
Example
SELECT CHAR_LENGTH('plus2net.com');
The output is 12
SELECT id, name, char_length(name) as LN FROM `student`
We will get a list of id , name and length like this
| id | name | LN |
|---|---|---|
| 1 | John Deo | 8 |
| 2 | Max Ruin | 8 |
| 3 | Arnold | 6 |
SELECT id, name FROM `student` WHERE char_length(mark) <=1
We can combine two columns by using CONCAT() function and then find out the length of the total string.
SELECT id,CONCAT(name,'-',class) as Name ,
CHAR_LENGTH(CONCAT(name,'-',class) ) as LN FROM `student`
Few rows are shown here. | id | Name | LN |
|---|---|---|
| 1 | John Deo-Four | 13 |
| 2 | Max Ruin-Three | 14 |
| - | -- | -- |
| 34 | Gain Toe-Seven | 14 |
| 35 | Rows Noump-Six | 14 |
| 39 | - | 1 |
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.