×

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 Invisible Index

Invisible Index MySQL index decides an option to the availability of the index for the query optimizer. This index shows the visible and invisible options to displays the index column in...

3 minutes read.

MySQL Union

MySQL contains the same categories of data in a different table. Sometimes, you require multiple tables to collect data together. MySQL union is a function to combine two table's data...

5 minutes read.

MySQL Subquery

The subquery is a MySQL query used to manage data operations. Mainly subquery helps to retrieve data with the necessary condition. It creates a nested query with two different queries....

5 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 Prefix index

Prefix index This index query creates an index column in the string or character column. MySQL system can create multiple indexes in the table. It will create in a table as...

3 minutes read.

MySQL LOAD_FILE() function

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

3 minutes read.

MySQL Advance table Query

MySQL Advance table Query The table is created by index, rows, and columns in the MySQL database. The user saves their information in matrix format. The database requires a query to...

14 minutes read.

MySQL EXPORT_SET() function

In this context, we will learn how we can use the MySQL EXPORT_SET() function with proper syntax and good examples. Introduction of MySQL EXPORT_SET() function This function returns a string and shows...

3 minutes read.

MySQL Constraints

MySQL Constraints Introduction The constraints help to restrict what values should be stored in a table. The constraints provide limitations of the columns or data. This function helps to insert data in...

20 minutes read.

MySQL LN() function

In this context, we will learn how we can use the MySQL LN() function with proper syntax and good examples. Introduction of MySQL LN() function For evaluation of the natural logarithm of...

2 minutes read.

MySQL ASIN() Function

In this context we will learn how we can use the ASIN() function in MySQL with proper syntax and good example. Introduction of MySQL ASIN() function The arc sine value of a...

2 minutes read.

MySQL FROM_BASE64() function

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

2 minutes read.

MySQL Aggregate function

The aggregation function works on the multiple values and returns single value output.  It makes the advanced and complex operation simple. The summation (SUM), MAX, AVG, MIN, COUNT functions are...

5 minutes read.

MySQL MONTHNAME() function

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

3 minutes read.

MySQL Database Introduction

MySQL - Database Introduction: The database plays an essential role in MySQL for storing and modifying the data. The database creates and keeps multiple tables. The database organizes and manipulates...

8 minutes read.

MySQL UPDATE JOIN

The UPDATE JOIN is a MySQL statement used to perform cross-table updates that means we can update one table using another table with the JOIN clause condition. The "update join"...

5 minutes read.

MySQL vs Oracle

What is MySQL? The open-source MySQL relational database management system is a vital software component for web-based applications. As the data is saved and sent over the internet, databases and related...

6 minutes read.

MySQL CEILING() function

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

2 minutes read.

MySQL MAX function

The MAX function is a type of aggregation function that determines the maximum value of the table data. This function works on numerical data type values. If the table displays...

4 minutes read.

MySQL RIGHT JOIN

MySQL right join links two tables with each other. The left table column connects with the complete right side table. Each row of the right table tries to connect with...

4 minutes read.