赞
踩
SQL中 OR条件左右只要有一个成立,就可以返回true结果,所以在和and使用得时候 ,OR必须要加上括号来使用。
- queryWrapper.and(Wrapper -> Wrapper.like("first_name", "nana").or().like("last_name ","nana"));
- queryWrapper.ge("actor_id",10);
- // 等同于 WHERE actor_id > 10 AND (first_name LIKE '%A%' OR last_name LIKE '%A%');
-
-
- queryWrapper.like("first_name", "nana").or().like("last_name ","nana");
- queryWrapper.ge("actor_id",10);
- // 等同于 WHERE actor_id > 10 AND first_name LIKE '%A%' OR last_name LIKE '%A%'; 这种写法是错误得
- if (StringUtils.isNotBlank(vo.getTitle())) {
- //queryWrapper.like("mt.title", vo.getTitle()).or().like("mt.message", vo.getTitle()); 错误拼接
- queryWrapper.and(Wrapper -> Wrapper.like("mt.title", vo.getTitle()).or().like("mt.message", vo.getTitle()));
- }
-
- SELECT COUNT(1) FROM message AS m LEFT JOIN message_text AS mt ON m.message_id = mt.id LEFT JOIN (SELECT count(1) AS un_read_count, rec_id FROM message WHERE status = 0 GROUP BY rec_id) AS m1 ON m.rec_id = m1.rec_id WHERE (m.rec_id = ? AND relevance_message_type IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND mt.update_time <= ? AND mt.update_time >= ? AND
- (mt.title LIKE ? OR mt.message LIKE ?)
- AND m.deleted = ?)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。