×

MySQL Character Length Function

In this context, we will learn how we can use the MySQL CHARACTER_LENGTH() function with proper syntax and good examples.

Introduction of MySQL CHARACTER_LENGTH() function

CHARACTER_LENGTH() function in MySQL is used to find the length of a given string (in characters). It counts the number of characters and ignores whether the character(s) are single-byte or multi-byte.

Syntax of the MySQL CHARACTER_LENGTH() function

The syntax of the MySQL CHARACTER_LENGTH() function is given as follows:

CHARACTER_LENGTH(string)

Parameters or arguments used in MySQL CHARACTER_LENGTH() function:

Only one parameter is accepted by the CHARACTER_LENGTH() function in MySQL, which is given as follows:

String: This is the String whose length is to be calculated.

Returns:

It will return the length of a given string.

Application used for CHARACTER_LENGTH() function:

The CHARACTER_LENGTH() function can be used in the given below MySQL versions.:

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1
  • MySQL 4.0
  • MySQL 3.23

Examples of MySQL CHARACTER_LENGTH() function:

Now we will look into some MySQL CHARACTER_LENGTH() function examples and will explore how we can use the CHARACTER_LENGTH function in MySQL.

Example-1 :

Here, we will derive the length for a String using the CHARACTER_LENGTH() function in MySQL.

SELECT CHARACTER_LENGTH("Javatpoint") AS LengthOfString

Output :

LengthOfString
10
1 row in set (0.00 sec)

Example-2 :

Here, we will derive the length for a String using the CHARACTER_LENGTH() function in MySQL.

SELECT CHARACTER_LENGTH("MYSQL Tutorial in javatpoint") AS LengthOfString

Output :

LengthOfString
28
1 row in set (0.00 sec)

Example-3 :

When we require to find the length of every String in a column of a Table, then we can take the help of the CHARACTER_LENGTH() function in MySQL.

CHARACTER_LENGTH() function finds the length for every String in a column of a Table.

Student_RollStudent_NameTotal_Marks
1Amit450
2Aniket470
3Sanjana432
4Nirmal475

Table – Student_Details

SELECT CHARACTER_LENGTH(Student_Name) AS LengthOfName FROM Student_Details;

Output :

LengthOfName
4
6
7
6

Application of MySQL CHARACTER_LENGTH() function:

This function is used to find the length of a given string (in characters).

Summary:

In the above context, we have learned how we can use the CHARACTER_LENGTH() function in MySQL used to find the length of a given string (in characters).


Related Topics

MySQL POWER() function

In this context, we will learn how we can use the MySQL POWER() function with proper syntax and good examples. Introduction of MySQL POWER() function The value of a number raised to...

3 minutes read.

MySQL Clauses

MySQL Clauses MySQL system clauses are keywords or statements to handle information. It helps to operate a group of the data and apply it to require conditions. The clauses apply conditions...

16 minutes read.

MySQL SELF JOIN

This join links table with itself. The inner join, a self join, a right join, and a cross join are connected with two or more two tables. But, the "self...

4 minutes read.

MySQL function

MySQL function is a piece of program to perform some specific task. Here we pass a parameter and then return a single value. MySQL function mainly supports string, numeric, conditional,...

9 minutes read.

MySQL RIGHT() Function

In this context, we will learn how we can use the MySQL RIGHT() Function with proper syntax and good examples. Introduction of MySQL RIGHT() function The RIGHT() function in MySQL is used...

3 minutes read.

MySQL RADIANS() function

In this context, we will learn how we can use the MySQL RADIANS() function with proper syntax and good examples. Introduction of MySQL RADIANS() function RADIANS() function in MySQL is used to...

2 minutes read.

MySQL Vs MongoDB

What is MongoDB? MongoDB is a distributed, open-source, cross-platform document-based database which was created to scale and develop applications simply. It was created as a NoSQL database by MongoDB Inc. MongoDB gets...

6 minutes read.

MySQL Data Types

Introduction of the Data types In the data file, we have several information such as names, numbers, marks, and other information. This information specifies categories such as numbers, characters, and decimal...

8 minutes read.

MySQL LOG() function

In this context, we will learn how we can use the MySQL LOG () function with proper syntax and good examples. Introduction of MySQL LOG() function The LOG() function in MySQL is...

3 minutes read.

MySQL RAND() function

In this context, we will learn how we can use the MySQL RAND() function with proper syntax and good examples. Introduction of MySQL RAND() function Basically, in MySQL the RAND() function is...

3 minutes read.

MySQL Index

An index is a widely used method to access table information quickly. MySQL requires an index for operating table data stored in rows and columns. It's an entry point of...

3 minutes read.

MySQL GREATEST function

This statement displays the greatest values of the table. The GREATEST function returns a null value when the table contains a null value. The GREATEST function needs a minimum of...

2 minutes read.

MySQL Features

Features of MySQL MySQL is a relational database management system (RDBMS): It is a collection of many programs and makes relations with many other programs. Easy to use MySQL database: MySQL...

2 minutes read.

MySQL Table

Introduction MySQL table is an essential part of the system. MySQL table stores data using index, rows, and columns. It accesses data from the server quickly because of the table—this table...

22 minutes read.

MySQL Queries

MySQL Queries MySQL supports SQL queries in the MySQL interface. These queries help to interact data with the application. MySQL uses create database, user database, create a table, truncate table, and...

13 minutes read.

MySQL MIN function

The MIN() function determines the minimum or lowest value of the data set. This function works on numerical data type values. If the table displays zero value, then the row...

4 minutes read.

MySQL RTRIM() function

In this context, we will learn how we can use the MySQL RTRIM() function with proper syntax and good examples. Introduction of MySQL RTRIM() function It is the function in MySQL that...

2 minutes read.

MySQL INSTR() Function

In this context, we will learn how we can use the MySQL INSTR() function with proper syntax and good examples. Introduction of MySQL INSTR() function This function in MySQL returns the location...

4 minutes read.

MySQL Character Length Function

In this context, we will learn how we can use the MySQL CHARACTER_LENGTH() function with proper syntax and good examples. Introduction of MySQL CHARACTER_LENGTH() function CHARACTER_LENGTH() function in MySQL is used to...

2 minutes read.

MySQL ELT() function

In this context, we will learn how we can use the MySQL ELT() function with proper syntax and good examples. Introduction of MySQL ELT() function In the ELT function, the number field...

2 minutes read.