-
mysql中使用exist以及and、or
普通类 -
- 支持
- 批判
- 提问
- 解释
- 补充
- 删除
-
-
exists的使用
SgFriendsGroupService.java
public PageList getAllFriendsNotCoAuthor(int offset, int pageCapacity,
Long psUserId, String searchname,Long resourceId,String type){
String totalsql="select count(sgf.id) from Sgfriends sgf,User us where us.id=sgf.userfriend.id and sgf.user.id=" + psUserId+ " and sgf.status=1";
totalsql +=" and NOT EXISTS (select kar from KoAuthorRelation kar where kar.user.id=sgf.userfriend.id and kar.authority=2 and kar.status=1 and kar.type='"+type+"' and kar.resourceId="+resourceId+")";
String sql = "select us from Sgfriends sgf,User us where us.id=sgf.userfriend.id and sgf.user.id=" + psUserId+ " and sgf.status=1";
sql +=" and NOT EXISTS (select kar from KoAuthorRelation kar where kar.user.id=sgf.userfriend.id and kar.authority=2 and kar.status=1 and kar.type='"+type+"' and kar.resourceId="+resourceId+")";
PageList pageList = this.dao.pageList(offset, pageCapacity, totalsql, sql);
return pageList;
}
-
and以及or的使用
-
-
- 标签:
- select
- string
- sgf.status
- sgf.userfriend.id
- id790
- pagelist
- exists
- mysql
- kar
- totalsql
- sql
-
学习元评论 (0条)
聪明如你,不妨在这 发表你的看法与心得 ~