In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article "mybatis QueryWrapper apply, last, select how to use" most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "mybatis QueryWrapper apply, last, select how to use" article.
Apply, last, select of QueryWrapper conditional Construction
Scenario: when querying a database to limit the number of entries
Limit on mysql uses QueryWrapper needSyn = new QueryWrapper (); needSyn.ge ("ModifyDate", lmtSynRec.getLatestDate ()); needSyn.last ("limit 200"); List needData = cusCarInfoMapper.selectList (needSyn)
If it is oracle, you can use apply.
NeedSyn.apply ("rownum"
< {0}" , 200);如果是sqlserver 建议自己写sql查询语句 select top ${top} * from CUS_CAR_INFO t where t.ModifyDate >Cast (# {latestDate} as datetime) orderBy t.ModifyDate ascList getSynList (int top, Date latestDate)
Or use QueryWrapper's select
QueryWrapper wrapper = new QueryWrapper (); wrapper.select ("top 200 *"); return this.list (wrapper)
The above is to query top data according to the latest time
The field passed in is of time type and is received with a # {} placeholder. If it is a specific number or character, you can receive it with ${}.
Conditional constructor QueryWrapper instance
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.
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.