当前位置:网站首页>MySQL uses list as a parameter to query
MySQL uses list as a parameter to query
2022-07-28 05:30:00 【wang0112233】
Summary : Two fields are needed to determine A piece of data , Name and... According to the queried data code Fuzzy query of
reflection :<foreach> Tags can be queried with single conditions , Can't meet demand , Need to carry out sql The joining together of , Use LambdaQueryWrapper Conduct sql Splicing , be used or(),and() Method , But because the query is sequential ,list Query and fuzzy query are using one layer , If it's just a simple use or () Splicing words ,like Fuzzy query will be invalid , Need to put list A collection of list Packaging
solve :
// obtain list object
List<RateOnlineUseDTO> onlineChannelList = baseMapper.getUseDetail(reserveRule.getRuleCode());
// Definition LambdaQueryWrapper
LambdaQueryWrapper<PrPriceplanHotel> queryWrapper = new LambdaQueryWrapper<>();
List<ReserveRuleUseDetailVO> reserveRuleUseDetailVOList = new ArrayList<>();
// Splice and query each list The object of
queryWrapper.and((wrapper) -> {
onlineChannelList.stream().forEach(rateOnlineChannel -> {
wrapper.or().eq(PrPriceplanHotel::getTemplateCode, rateOnlineChannel.getRateCode())
.eq(PrPriceplanHotel::getHotelCode, rateOnlineChannel.getHotelCode());
});
});
// Splice fuzzy queries
if (StringUtils.isNotEmpty(req.getKeyword())) {
queryWrapper.and(wq -> wq
.like(PrPriceplanHotel::getTemplateCode, req.getKeyword())
.or()
.like(PrPriceplanHotel::getTemplateName, req.getKeyword()));
}
// Return the data
List<PrPriceplanHotel> priceplanHotelList = iPrPriceplanHotelService.list(queryWrapper);Printed sql
SELECT
id,
CODE,
NAME
FROM
pr_otel
WHERE
((
templat = ?
AND hotel = ?
OR template = ?
AND hotel = ?
OR template = ?
AND hotel = ?
)
AND (
template_co LIKE ?
OR template_na LIKE ?))边栏推荐
- Mysql处理遗留数据样例
- New methods and features of ES6 built-in objects
- Google browser cannot open localhost:3000. If you open localhost, you will jump to the test address
- mybaties foreach多选查询,index循环,取消and/or标签
- 注册中心服务eureka 切换到 nocas遇到的问题
- Advanced assignment method of ES6 -- Deconstruction assignment
- Interpretation of afnetworking4.0 request principle
- docker 部署 mysql5.7.35
- Microservice failure mode and building elastic system
- oracle查看锁表语句、解锁方法
猜你喜欢

CentOS7安装MySQL5.7

Scope, execution process and life cycle of bean

2022 summer practice (PowerDesigner tutorial learning record) (first week)

BigDecimal 进行四舍五入 四舍六入和保留两位小数

repackag failed: Unable to find main class

ES6 new variable modifiers let and const, new basic data type symbol

Duoyu security browser will improve the security mode and make users browse more safely

论文写作用词

From the basic concept of micro services to core components - explain and analyze through an example

Why is MD5 irreversible, but it may also be decrypted by MD5 free decryption website
随机推荐
11.< tag-动态规划和子序列, 子数组>lt.115. 不同的子序列 + lt. 583. 两个字符串的删除操作 dbc
How about ink cloud?
How does Alibaba use DDD to split microservices?
【ARXIV2205】EdgeViTs: Competing Light-weight CNNs on Mobile Devices with Vision Transformers
图像增强——MSRCR
Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
数据库日期类型全部为0
多线程进阶:volatile的作用以及实现原理
Printf function of input and output function in C language
Jsonp single sign on permission verification
LocalDateTime去掉T,JSONField失效
Non functional test
使用navicat或plsql导出csv格式,超过15位数字后面变成000(E+19)的问题
Mysql处理遗留数据样例
MySQL basic query
You must configure either the server or JDBC driver (via the ‘serverTimezone)
【idea插件神器】教你如何使用IDEA一键set实体类中所有属性
C language: some self realization of string functions
图像增强评价指标学习之——结构相似性SSIM
JMeter related knowledge sorting