Mysql numeric type conversion function

  • 2020-05-07 20:35:41
  • OfStack

1. Convert Int to varchar often concat functions are used, such as concat(8,'0') to get the string '80'
2. Convert varchar to Int with cast(a as signed) a as varchar string
Conclusion: the type conversion is like SQL Server1, that is, the type parameters are slightly different: CAST(xxx AS type), CONVERT(xxx type)
Available types
Base 2, with the binary prefix: BINARY
Character type, with parameter: CHAR()
Date: DATE
Time: TIME
Date time type: DATETIME
Floating point number: DECIMAL
Integer: SIGNED
Unsigned integer: UNSIGNED

Related articles: