The following article mainly introduces how to use the MySQL numeric type to correctly convert the function (concat/cast) to the actual operation process, and the projects in the actual operation are worth noting, the following is a description of the specific content. I hope it will be helpful for your future study.
1. The concat function is often used to convert Int to varchar. For example, concat (8, '0') gets the string '80 ′
2. Convert varchar into an Int string of the varchar type using cast (a as signed).
Summary: type conversion is similar to SQL Server, that is, the type parameters are slightly different: CAST (xxx AS type), CONVERT (xxx, type)
Available types in the MySQL numeric type conversion function (concat/cast)
Binary, with a BINARY Prefix: binary
Character type, with parameters: CHAR ()
DATE: DATE
TIME: TIME
DATETIME type
Floating Point: DECIMAL
Integer: SIGNED
UNSIGNED integer
Cast function running example
- mysql> select cast(‘125e342.83′ as signed) as clm1, cast(‘foo seo 589′ as signed) as clm2,cast(‘3.35′ as signed) as clm3;
- +——+——+——+
- | clm1 | clm2 | clm3 |
- +——+——+——+
- | 125 | 0 | 3 |
- +——+——+——+
- 1 row in set, 3 warnings (0.00 sec)
- mysql>
The above content is an introduction to the MySQL numeric type conversion function (concat/cast). I hope you will get some benefits.