Declaration
CONVERT(expr USING transcoding_name)
CONVERT(expr,type)
Description
The two declarations of the CONVERT() function correspond to two different applications:
CONVERT(expr USING transcoding_name)is used to convert the expressionexprto the character set specified bytranscoding_name.CONVERT(expr,type)is used to convert the expressionexprto the data type specified bytype.In this usage,
CONVERT(expr,type)is identical toCAST(expr AS type). For more information about theCASTfunction, see CAST.
Examples
Changed the character set used by the string to
BINARY.obclient> SELECT CHARSET(CONVERT('abc' USING binary)); +--------------------------------------+ | charset(CONVERT('abc' USING binary)) | +--------------------------------------+ | binary | +--------------------------------------+ 1 row in setSpecify the string type as
CHAR.obclient> SELECT CONVERT('test', CHAR); +-----------------------+ | CONVERT('test', CHAR) | +-----------------------+ | test | +-----------------------+ 1 row in set