Syntax:
CAST(expr AS type)

CAST(expr AS type takes an expression of any type and produces a result
value of the specified type. This operation may also be expressed as
CONVERT(expr, type), which is equivalent.

These type values are permitted:

o BINARY[(N)]

  Produces a string with the VARBINARY data type, except that when the
  expression expr is empty (zero length), the result type is BINARY(0).
  If the optional length N is given, BINARY(N) causes the cast to use
  no more than N bytes of the argument. Values shorter than N bytes are
  padded with 0x00 bytes to a length of N. If the optional length N is
  not given, MySQL calculates the maximum length from the expression.
  If the supplied or calculated length is greater than an internal
  threshold, the result type is BLOB. If the length is still too long,
  the result type is LONGBLOB.

  For a description of how casting to BINARY affects comparisons, see
  https://dev.mysql.com/doc/refman/5.7/en/binary-varbinary.html.

o CHAR[(N)] [charset_info]

  Produces a string with the VARCHAR data type. except that when the
  expression expr is empty (zero length), the result type is CHAR(0).
  If the optional length N is given, CHAR(N) causes the cast to use no
  more than N characters of the argument. No padding occurs for values
  shorter than N characters. If the optional length N is not given,
  MySQL calculates the maximum length from the expression. If the
  supplied or calculated length is greater than an internal threshold,
  the result type is TEXT. If the length is still too long, the result
  type is LONGTEXT.

  With no charset_info clause, CHAR produces a string with the default
  character set. To specify the character set explicitly, these
  charset_info values are permitted:

  o CHARACTER SET charset_name: Produces a string with the given
    character set.

  o ASCII: Shorthand for CHARACTER SET latin1.

  o UNICODE: Shorthand for CHARACTER SET ucs2.

  In all cases, the string has the character set default collation.

o DATE

  Produces a DATE value.

o DATETIME[(M)]

  Produces a DATETIME value. If the optional M value is given, it
  specifies the fractional seconds precision.

o DECIMAL[(M[,D])]

  Produces a DECIMAL value. If the optional M and D values are given,
  they specify the maximum number of digits (the precision) and the
  number of digits following the decimal point (the scale). If D is
  omitted, 0 is assumed. If M is omitted, 10 is assumed.

o JSON

  Produces a JSON value. For details on the rules for conversion of
  values between JSON and other types, see
  https://dev.mysql.com/doc/refman/5.7/en/json.html#json-comparison.

o NCHAR[(N)]

  Like CHAR, but produces a string with the national character set. See
  https://dev.mysql.com/doc/refman/5.7/en/charset-national.html.

  Unlike CHAR, NCHAR does not permit trailing character set information
  to be specified.

o SIGNED [INTEGER]

  Produces a signed BIGINT value.

o TIME[(M)]

  Produces a TIME value. If the optional M value is given, it specifies
  the fractional seconds precision.

o UNSIGNED [INTEGER]

  Produces an unsigned BIGINT value.

URL: https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html

