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

A case study of pits sorted by mybatis-plus QueryWrapper

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of the pit case analysis of mybatis-plus QueryWrapper sorting, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this mybatis-plus QueryWrapper ranking pit case analysis article. Let's take a look at it.

Pit sorted by QueryWrapper

It can be summed up into the above two sentences.

Conditional constructor QueryWrapper

Let's take a few more examples to delve into the use of the conditional constructor QueryWrapper:

Case one

Check for employees surnamed Li with birth dates ranging from 1993-02-09 to 1994-04-09

Sql implementation:

SELECT * FROM t_employee WHERE DATE_FORMAT (birthday,'%Y-%m-%d') > = '1993-02-09' AND DATE_FORMAT (birthday,'%Y-%m-%d') = '1993-02-09' AND DATE_FORMAT (birthday,'%Y-%m-%d') wq.isNotNull ("email"). Eq ("gender", "female"); List employeeList = employeeMapper.selectList (queryWrapper); System.out.println (employeeList);} case three

Query employees surnamed Li and whose mailbox is not empty or female.

Sql implementation:

SELECT * FROM t_employee WHERE NAME LIKE 'Lee%' AND (email IS NOT NULL OR gender = 'female')

Mp implementation:

/ * query employees surnamed Li and whose mailbox is not empty or female * sql:SELECT * FROM t_employee WHERE NAME LIKE'Li% 'AND (email IS NOT NULL OR gender =' female') * / @ Testpublic void selectByQueryWrapper5 () {QueryWrapper queryWrapper=new QueryWrapper (); / / QueryWrapper queryWrapper2=Wrappers.query (); queryWrapper.likeRight ("name", "Li") .and (wq- > wq.isNotNull ("email"). Or (). Eq ("gender", "female")) List employeeList = employeeMapper.selectList (queryWrapper); System.out.println (employeeList);} case four

The employees whose salary is less than or equal to 3500 are displayed in the order of age, according to the order of age, which belongs to department No. 1 and 2, and whose salary is less than or equal to 3500.

Sql implementation:

SELECT * FROM t_employee WHERE salary

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