Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

MySQL String ORD Function

The MySQL string ORD function is one of the MySQL String Functions, which is to find the code of the leftmost character in a string.

  • If the leftmost character is multibyte, the ORD function uses the formula to calculate the code: (1st-byte code) + (2nd-byte code *256) + (3rd-byte code * 256^2)….
  • If the leftmost character is not a multibyte character, this MySQL string ORD function writes the ASCII code of that byte.

MySQL String ORD Syntax

The basic syntax of the ORD string in MySQL is as shown below.

ORD(String)

MySQL ORD Function Example

The following query shows multiple ways to use this MySQL String ORD function. Here, we used only single characters; that’s why this function returns the ASCII values of those characters.

SELECT ORD('A');

SELECT ORD('1');

SELECT ORD('@');
MySQL String ORD Function 1

Within the first two statements, we used multiple values. However, this MySQL function returns the ASCII code value of the first character. In the third statement, we used a different character. So, this String Function used the formula to get that code.

SELECT ORD('ABC');

SELECT ORD('213');

SELECT ORD('¥z');
MySQL ORD Function 2

Filed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021· All Rights Reserved by Suresh.
About | Contact | Privacy Policy