mybatis-pus使用and or条件查询
程序员文章站
2024-03-02 08:05:46
...
QueryWrapper<Site> queryWrapper = new QueryWrapper();
queryWrapper.eq("is_citys",1);
queryWrapper.and(query->query.eq("site_id",1).or().eq("site_id",777));
siteService.list(queryWrapper);
LambdaQueryWrapper<Site> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Site::getIsCitys,0).and(query->query.eq(Site::getSiteId,6).or().eq(Site::getSiteId,777));
siteService.list(lambdaQueryWrapper);
查询sql打印
SELECT
site_id,
is_citys
FROM
site
WHERE
(is_citys = 0
AND (site_id = 1
OR site_id = 777))
上一篇: SQL的多条件查询语句