TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    MySQL

    MySQL CHAR_LENGTH Function

    Overview

    In this tutorial, we will learn about the MySQL CHAR_LENGTH Function. This function returns the
    length of the string i.e the umber of characters in the string.

    Syntax

    The general the syntax for a function call includes the function name followed by parenthesis
    (which contains the String argument):

    CHAR_LENGTH(string_argument)

    This function can be invoked with a string argument or column names. The function returns the number that is used in place of the function call when the expression is evaluated.

    Examples

    In the first example, we will call the function with a sample string argument. Let’s count the number of characters in the string ‘abcd’.

    mysql> SELECT CHAR_LENGTH(‘abcd’);
    +———————+
    | CHAR_LENGTH(‘abcd’) |
    +———————+
    | 4 |
    +———————+

    MySQL CHAR_LENGTH Function

    In the next example, we will calculate the number of characters in a table column. We will consider the
    Country database table from the world MYSQL database. The Name column is a String datatype column CHAR/VARCHAR.

    mysql> SELECT Name, CHAR_LENGTH(Name)
                 -> FROM Country
                 -> WHERE Continent = ‘North America’;

     

    MySQL CHAR_LENGTH Function Column Name

    There is a notable difference between CHAR_LENGTH and LENGTH functions.  CHAR_LENGTH() counts multi-byte character as a single character. For example, for a string containing seven 2-byte characters, LENGTH() returns 14, whereas CHAR_LENGTH() function returns 7.

    —

    MySQL Tutorials

    MySQL Tutorials on this website:

    https://www.testingdocs.com/mysql-tutorials-for-beginners/

    For more information on MySQL Database:

    https://www.mysql.com/

    Related Posts

    Stellar Converter for Database Tool

    MySQL /

    Stellar Converter for Database

    Stellar MySQL Log Analyzer

    MySQL /

    Stellar Log Analyzer for MySQL

    Stellar Repair for MySQL

    MySQL /

    Stellar Repair for MySQL

    MySQL /

    How to secure your SQL Database: Tips and Tricks

    Stellar Converter for Database

    MySQL /

    Database Converter Tools

    ‹ MySQL Trigonometry Functions› MySQL INSTR Function

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com