In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the method of comparing the size of varchar type numbers in MySQL database". In the daily operation, it is believed that many people have doubts about the method of comparing the size of varchar type numbers in MySQL database. The editor consulted all kinds of data and sorted out simple and useful operation methods. I hope it will be helpful for you to answer the question of "what is the method of comparing the size of varchar numbers in MySQL database?" Next, please follow the editor to study!
Create a test table-Table structure for check_test-- DROP TABLE IF EXISTS `check_ test` CREATE TABLE `check_ test` (`id` int (11) NOT NULL AUTO_INCREMENT, `current_ price` varchar (10) NOT NULL, `price` varchar (10) NOT NULL, PRIMARY KEY (`id`) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 -Records of check_test-- INSERT INTO `check_ test` VALUES ('1x, '12m,' 14'); INSERT INTO `check_ test` VALUES ('2th,' 22th, '33') INSERT INTO `check_ test`VALUES ('315,' 8'); INSERT INTO `check_ test`VALUES ('44th,' 94th,'7'); INSERT INTO `check_ test`VALUES ('54th,' 124th, '12.9')
We execute the following SQL:
-- find the record select * from check_test where current_price (price+0) whose current_price is smaller than price.
The results are as follows:
We can see that in result 1, 15 > 8 does not meet the condition, but it is queried, while in result 3, 15 > 8 is satisfied, but not queried.
Why is that? Because the numeric comparison size of the string type starts from the first bit to compare its corresponding numerical size in the character encoding, equality continues to compare the second bit, and the difference is that the larger numeric value is larger. The ASCII code value for numeric characters is as follows:
For example:
If current_price= "12" and price= "14", where the first character "1" corresponds to an ASCII decimal value of 49, the two are equal, while the ASCII decimal value of the second character "2" is 50, and the ASCII decimal value of "4" is 52
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.