标签:user entity select ide example alt stat sql status
想要进行select * from A where (xx=a and xx=b) or (xx=c and xx=d)的查询操作
xx可以为A表中的任意属性,前面括号里的xx可以和后面括号的相同也可以不同
具体写法
OrderEntityExample example=new OrderEntityExample();
cn.jiliangqiju.entity.b2b.OrderEntityExample.Criteria criteria = example.createCriteria();
criteria.andCreatEqualTo(userid);
criteria.andIdEqualTo(id);
cn.jiliangqiju.entity.b2b.OrderEntityExample.Criteria criteria2 = example.createCriteria();
criteria2.andNoEqualTo(no);
criteria2.andStatusEqualTo(status);
example.or(criteria2);//这个是重点
执行的sql是select* from order where (id =id and creat =creat)or(no=no and status=status)
如果想要执行select * from A where (xx=a ) or (yy=c ) and zz=d的操作,目前没想到什么合适的方法,可以转变成
select * from A where (xx=a and zz=d ) or (yy=c zz=d)
这样就和上面一样了
标签:user entity select ide example alt stat sql status
原文地址:http://www.cnblogs.com/hardwork1/p/7685020.html