Name

CAST( )

Synopsis

CAST(expression AS type)

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. This function is synonymous with CONVERT(), 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.