Mysql number type conversion function method: 1. Use the function concat to convert Int to varchar; 2. Use [cast(a as signed) a] to convert varchar to Int.
More related free learning recommendation: mysql tutorial (video)
Mysql number type Method of conversion function:
1. Convert Int to varchar often use the concat function, such as concat(8,'0') to get the string '80& #39;
and MENU_NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),' %')
2. Convert varchar to Int and use cast(a as signed) a to varchar type string
Summary: type conversion is the same as SQL Server, The type parameter is a bit different: CAST(xxx AS type), CONVERT(xxx, type)
Available types
-
Binary, same effect with binary prefix: BINARY
-
Character type, can take parameters: CHAR()
-
Date: DATE
-
Time: TIME
-
DateTime: DATETIME
-
Float: DECIMAL
-
Integer: SIGNED
-
Unsigned Integer: UNSIGNED
SELECT * from sys_menu where PARENT_ID='0' ORDER BY cast(MENU_NO as signed)
When MENU_NO
is a letter or Chinese character, the converted number is 0.
3. When we want to modify the sorting of a user list frequently, we need It is used when the serial number is a decimal. Because if it is an integer, then after adjusting the first one, all subsequent numbers must be adjusted. So we use decimals to sort.
For example 3 3.1 3.2 3.201 3.9 4
In sql we need
order by u.NUMBER+ 0 The mysql database type of NUMBER is varchar.
The above is the detailed content of how to convert the Mysql number type. For more information, please pay attention to other related articles on 1024programmer.com!