asp.net企业网站管理系统,平面广告图片,wordpress主题网,南京网站设计公司兴田德润电话多少【引言】
使用mybatis-plus框架的基础上#xff0c;直接使用其中的条件参数进行查询还是很方便的。但每次使用到像大于、不等于这样一些不常用条件时#xff0c;都需要现查#xff0c;所以记录在这篇博客里#xff0c;当作一个自己的查询手册。
【手册】
查询方式说明se…【引言】
使用mybatis-plus框架的基础上直接使用其中的条件参数进行查询还是很方便的。但每次使用到像大于、不等于这样一些不常用条件时都需要现查所以记录在这篇博客里当作一个自己的查询手册。
【手册】
查询方式说明select设置查询字段andAND 语句拼接 AND (字段值)orOR 语句拼接 OR (字段值)eq等于allEq基于 map 内容等于ne不等于gt大于ge大于等于lt小于le小于等于like模糊查询notLike模糊查询 NOT LIKEinIN 查询notInNOT IN 查询isNullNULL 值查询isNotNullIS NOT NULLgroupBy分组 GROUP BYhavingHAVING 关键词orderBy排序 ORDER BYorderAscASC 排序 ORDER BYorderDescDESC 排序 ORDER BYexistsEXISTS 条件语句notExistsNOT EXISTS 条件语句betweenBETWEEN 条件语句notBetweenNOT BETWEEN 条件语句last拼接在最后例如last(“LIMIT 1”)
【示例】
select查询指定字段
代码使用
//查询作者和编码字段返回Article中其他字段的值均为null
public Article searchOne(Integer id) {LambdaQueryWrapperArticle queryWrapper new LambdaQueryWrapper();queryWrapper.select(Article::getAuthor,Article::getCode).eq(Article::getId,id);return articleMapper.selectOne(queryWrapper);
}sql打印
and和or并且或者条件
代码使用
public ListArticle searchMore(String keywords) {LambdaQueryWrapperArticle queryWrapper new LambdaQueryWrapper();queryWrapper.eq(Article::getCatId,10);queryWrapper.and(x-x.like(Article::getKeywords,keywords).or().like(Article::getTitle,keywords));return articleMapper.selectList(queryWrapper);
}sql打印
ge大于等于条件
代码使用
//查询条件访问量大于等于100
public ListArticle searchByCondition() {LambdaQueryWrapperArticle queryWrapper new LambdaQueryWrapper();//大于等于queryWrapper.ge(Article::getVisits,100);//查询指定字段queryWrapper.select(Article::getAuthor,Article::getCode,Article::getTitle,Article::getVisits);return articleMapper.selectList(queryWrapper);
}sql打印
in批量条件
代码使用
//栏目Id属于10和20的
public ListArticle searchByCondition() {LambdaQueryWrapperArticle queryWrapper new LambdaQueryWrapper();//inLong[] catId {10L,20L};ListLong catList Arrays.asList(catId);queryWrapper.in(Article::getCatId,catList);//查询指定字段queryWrapper.select(Article::getAuthor,Article::getCode,Article::getTitle,Article::getVisits);return articleMapper.selectList(queryWrapper);
}sql打印:
between范围条件
代码使用
//查询发布时间在2020-05-01至2020-06-25
public ListArticle searchByCondition() {LambdaQueryWrapperArticle queryWrapper new LambdaQueryWrapper();//betweenqueryWrapper.between(Article::getPublishTime, LocalDate.of(2020,5,1),LocalDate.now().plusMonths(1));//查询指定字段queryWrapper.select(Article::getAuthor,Article::getCode,Article::getTitle,Article::getVisits);return articleMapper.selectList(queryWrapper);
}sql打印
order排序条件
代码使用
//查询指定栏目下所有并按访问量和创建时间排序
public ListArticle searchByCondition() {LambdaQueryWrapperArticle queryWrapper new LambdaQueryWrapper();queryWrapper.eq(Article::getCatId,20);//查询指定字段queryWrapper.select(Article::getAuthor,Article::getCode,Article::getTitle,Article::getVisits);//按访问量和创建时间排序queryWrapper.orderByDesc(Article::getVisits).orderByAsc(Article::getCreateTime);return articleMapper.selectList(queryWrapper);
}sql打印