Name

CONVERT( )

Synopsis

CONVERT(expression, type)
CONVERT(expression USING transcoding)

Use this function to convert a value from one datatype to another. This function is available as of Version 4.0.2 of MySQL. For the first syntax shown, the datatype given as the second argument can be BINARY, CHAR, DATE, DATETIME, SIGNED [INTEGER], TIME, or UNSIGNED [INTEGER]. BINARY converts a string to a binary string. CHAR conversion is available as of Version 4.0.6 of MySQL. The second syntax shown allows for transcoding (character set) names to be given instead of datatypes. This function is synonymous with CAST( ), although the syntax is different.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.