The following operations are supported with the
CAST()
function.
CAST()
ofVARLEN
DATE
,DATETIME
,TIME
, andYEAR
column values toDOUBLE
.CAST()
of string column values to temporal types such asDATE
,DATETIME
,TIME
, andYEAR
.CAST()
ofTIME
,DATETIME
,TIMESTAMP
, andDATE
values toREAL
,TIME
,DATETIME
,DATE
, andYEAR
.CAST()
of values fromDATETIME
,TIMESTAMP
,DATE
, andTIME
types toDOUBLE
.-
CAST()
ofDECIMAL
andINTEGER
types toDECIMAL
. For example:mysql> CAST(c1 AS DECIMAL(5,2))
CAST()
ofENUM
columns toCHAR
,DECIMAL
,FLOAT
, and toSIGNED
andUNSIGNED
numeric values.CAST()
operates on theENUM
index rather than theENUM
values.