Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of Mysql Digital Type conversion function

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the method of Mysql digital type conversion function, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The method of Mysql numeric type conversion function: 1. Use the function concat to convert Int into varchar;2, and use [cast (an as signed) a] to convert varchar into Int.

The method of Mysql digital type conversion function:

1. Convert Int to varchar and often use concat functions, such as concat (8) to get the string '80'.

And MENU_NAME LIKE CONCAT (CONCAT ('%', # {pd.keywords}),'%')

2. Convert varchar to Int string of type varchar with cast (an as signed) a

Summary: type conversion is the same as SQL Server, except that the type parameters are slightly different: CAST (xxx AS type), CONVERT (xxx, type)

Available types

Binary, same effect with binary prefix: BINARY

Character type, with parameter: CHAR ()

Date: DATE

Time: TIME

Date and time type: DATETIME

Floating point numbers: DECIMAL

Integer: SIGNED

Unsigned integers: 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. 5.

3. When we often modify the sorting of a user list, we need to use the decimal number. Because if it is an integer, then if you adjust the first one, you have to adjust all the subsequent numbers. So we use decimals to sort.

For example, 3 3.1 3.2 3.201 3.9 4

In sql, we need

The mysql database type for order by u.NUMBER+0NUMBER is varchar. The above is all the contents of the method of Mysql digital type conversion function, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report