In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you the mybatis numerical string comparison example analysis, I hope you have something to gain after reading this article, let's discuss it together!
During the development of mybatis, it is necessary to determine which table to query in sql, as follows: sql:
SELECT a.tag_name, a.tag_id, count( 0 ) AS base_total FROM mm_dd_body a LEFT JOIN ccc AS b ON b.tag_body_id = a.id WHERE a.tag_base_cat = #{tagType} AND a.del = 0
At runtime, it is found that no matter what value tagType passes, it will not enter the two if. After analysis,'1' will be converted to a number, so there are two schemes here: Scheme 1: convert the parameter to int type, and then compare.
LEFT JOIN ccc AS b ON b.tag_body_id = a.id
Option 2: Convert numbers to strings, add.toString(), as follows:
LEFT JOIN ccc AS b ON b.tag_body_id = a.id
Of course, the above design is not a good design. It violates the principle of single responsibility. You can separate the if judgment into two separate selects, and then judge which one to use at the business layer. This is also a good solution, which can avoid many pits.
After reading this article, I believe you have a certain understanding of "mybatis numerical string comparison example analysis", if you want to know more related knowledge, welcome to pay attention to the industry information channel, thank you for reading!
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.