mybatis——逆向工程中 where (条件1)and (条件2 or 条件3 or 条件4)
where (条件1)and (条件2 or 条件3 or 条件4)
= where (条件1 and 条件2)or (条件1 and 条件3) or (条件1 and 条件4)
结果 是这样的
WHERE ( birthdate between ? and ? and username like ? ) or( birthdate between ? and ? and email like ? ) or( birthdate between ? and ? and phone like ? )
1. 在Example中每一个criteria相当于一个括号,把里面的内容当作一个整体。
Where(userid=’1’ and name=’2’)
1 2 3 4 | UserExample example = new UserExample(); UserExample.Criteria c1 = example.createCriteria(); C1.andUseridEqualTo(“ 1 ”); C2.andNameEqualTo(“ 2 ”); |
<code>C1.andUseridEqualTo(“
1
”)
.andNameEqualTo(“2
”);也可
2. 在criteria中没有直接的or。
(1) where(A and B) or (C and D)
1 2 3 4 5 6 7 8 | BasePointsExample.Criteria criteria1 = example.createCriteria(); criteria1.andUseridEqualTo( ‘11‘ ); criteria1.andPointnameLike(StringUtil.concatlike( ‘22‘ )); BasePointsExample.Criteria criteria2 = example.createCriteria(); criteria2.andUsernameEqualTo( ‘33‘ ); criteria2.andPointcontentLike(StringUtil.concatlike( ‘44‘ )); example.or(criteria2); |
(2)where A and (B or C)
==>(A and B) or (A and C)
1 2 3 4 5 6 7 8 | BasePointsExample.Criteria criteria1 = example.createCriteria(); criteria1.andUseridEqualTo( ‘11‘ ); criteria1.andPointnameLike(StringUtil.concatlike( ‘22‘ )); BasePointsExample.Criteria criteria2 = example.createCriteria(); criteria2.andUseridEqualTo( ‘11‘ ); criteria2.andPointcontentLike(StringUtil.concatlike( ‘33‘ )); <span> </span> example.or(criteria2);
|
相关推荐
flydoging 2020-06-07
疯狂紫萧 2020-05-29
yunzhonmghe 2020-05-19
米虚 2020-05-19
flydoging 2020-05-05
WflytoC 2020-05-01
沉浮于世 2020-04-08
yunzhonmghe 2020-04-07
kevincheung 2020-03-28
milidou 2020-02-22
licwwqy 2020-02-18
licwwqy 2020-01-23
milidou 2020-01-11
米虚 2020-01-05
milidou 2020-01-04
WflytoC 2019-12-19
沉浮于世 2019-12-07
沉浮于世 2019-11-17