Cnd cnd = Cnd.NEW();
if (!Strings.isBlank(src)) {
cnd.and("srcFrom", "=", src);
}
if (!Strings.isBlank(name)) {
String[] n = StringUtils.split(name, " ");
SqlExpressionGroup group = new SqlExpressionGroup();
for (String s : n) {
SqlExpression sqlExpression = Cnd.exp("srcName", "like", "%" + s + "%");
group.or(sqlExpression);
}
cnd.and(group);
}
cnd.and(Cnd.exps("productSku", "=", "").or("productSku", "is", null));
精华
SqlExpressionGroup SqlExpression Cnd 子查询组合查询示例代码(方便下次检索)
标签:
无
1 回复
Cnd cnd = Cnd.NEW();
cnd.and("gameNumber", "=", gameNumber);
SqlExpressionGroup group = new SqlExpressionGroup();
SqlExpressionGroup group1 = Cnd.exps("countDate", ">=", statDate).and("countDate", "<=", endDate);
SqlExpressionGroup group2 = Cnd.exps("countDate", ">=", "2017-01-01").and("countDate", "<=", "2018-01-01");
group.and(group1).or(group2);
cnd.and(group);
最后拼接结果:WHERE game_number='XJXQY'
AND ((count_date >= '2018-09-26' AND count_date <= '2018-12-26') OR (count_date >= '2017-01-01' AND count_date <= '2018-01-01'));
添加回复
请先登陆