Mysql numeric 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 recommendations: mysql tutorial(video)
Mysql numeric type conversion function method:
1. Convert Int to varchar often use the concat function, such as concat(8,'0') to get the string '80'
and MENU_NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
2. Convert varchar to Int using cast(a as signed) a is a string of varchar type
Summary: Type conversion is the same as SQL Server, but the type parameters are a little different: CAST(xxx AS type ), CONVERT(xxx, type)
Available types
Binary, with the effect of binary prefix: BINARY
Character type, can take parameters: CHAR()
Date: DATE
Time: TIME
Date time type: DATETIME
Floating point: 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 need to frequently modify the sorting of a user list, we need to use the situation where 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 NUMBER 的mysql数据库类型为varchar。
The above is the detailed content of How to convert function in Mysql numeric type. For more information, please follow other related articles on the PHP Chinese website!