CONVERT()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Converts the given value from one character set encoding to another.
USAGE
CONVERT(string USING charset)
Argument Name | Description |
---|---|
| The string to convert |
| The desired character set to use |
DETAILS
CONVERT()
is a type-conversion function that converts a string
from one character set encoding to another.
The CONVERT(expr USING charset)
syntax converts a string into the specified character set encoding.
A NULL
is returned if the string
argument is NULL
.
EXAMPLES
SELECT CONVERT('mariadb' USING utf8mb4);
+----------------------------------+
| CONVERT('mariadb' USING utf8mb4) |
+----------------------------------+
| mariadb |
+----------------------------------+
ERROR HANDLING
Unknown character set
The CONVERT()
function requires a known character set to be specified after the USING
clause. If an unknown name is specified, the following error is generated:
SELECT CONVERT('A' USING foo);
ERROR 1115 (HY000): [28674] Invalid character set/collation: Cannot find charset foo