Syntax
CONVERT(expr USING transcoding_name)
CONVERT(expr,type)
Purpose
The two syntaxes for the CONVERT() function are used for the following two purposes:
CONVERT(expr USING transcoding_name)changes the character set of the expressionexprto the character set specified bytranscoding_name.CONVERT(expr,type)changes the data type of the expressionexprto the data type specified bytype.CONVERT(expr,type)is equivalent toCAST(expr AS type). For more information about theCASTfunction, see CAST.
Examples
Change the character set of the string to
BINARY:obclient> SELECT CHARSET(CONVERT('abc' USING binary)); +--------------------------------------+ | charset(CONVERT('abc' USING binary)) | +--------------------------------------+ | binary | +--------------------------------------+ 1 row in setSet the data type of the string to
CHAR:obclient> SELECT CONVERT('test', CHAR); +-----------------------+ | CONVERT('test', CHAR) | +-----------------------+ | test | +-----------------------+ 1 row in set