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

How to realize the reverse order of time with the queryWrapper of MybatisPlus

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this article, the editor introduces in detail "how to use MybatisPlus's own queryWrapper to achieve time reversal", the content is detailed, the steps are clear, and the details are handled properly. I hope this "how to use MybatisPlus's own queryWrapper to achieve time reversal" article can help you solve your doubts.

MybatisPlus comes with queryWrapper time reverse queryWrapper.select (). OrderByDesc ("create_time")

Using queryWrapper to solve the sorting problem of numbers in strings

Today we encountered the problem of string sorting in Oracle database (including numbers). Here is a record of how to use MyBatis-Plus 's queryWrapper conditional constructor to solve the problem.

The cause

The database field is of type varchar (there is no problem if it is of type Number)

The sorting of database strings is compared bit by bit in order and by ascII code value. For example, 2 is bigger than 1, so 12 will rank before 2

Solution.

Sort by string length and then by field

Key code (queryWrapper conditional constructor implementation)

/ / use the database length function to obtain the string length (code here is the field name in my database) queryWrapper.orderByAsc ("length (code), code")

The reason why you can write this is because the parameter values in the orderBy of mybatis-plus are eventually concatenated after the order by of the sql statement, not only the column name of the database, so you only need to make the parameter values in the orderBy method conform to the sorting rules in sql to achieve the desired sorting results.

After reading this, the article "how to use the queryWrapper that comes with MybatisPlus to reverse the order of time" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, you are 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

Development

Wechat

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

12
Report