mybatisplus多条件并列复杂查询

在使用mybatisPlus时,有时需要一些负责的sql条件拼接,这时,我们可以利用 QueryWrapper的and(Consumer consumer) 和 or(Consumer consumer) 来对条件进行拼接。

查询条件拼接, 例如:(a and b) OR (c or d)

WHERE is_deleted='n' AND (refund_sts = ? AND ( (apply_type = ? AND return_money_sts = ?) ) OR ( (change_sts = ? AND apply_type = ?) ) AND express_no IS NULL AND express_name IS NULL) ORDER BY apply_time DESC LIMIT ?,?

转化为sql时:

WHERE is_deleted='n' 
AND (refund_sts = 2 
AND ( (apply_type = 2 AND return_money_sts = 0) ) 
OR ( (change_sts = 1 AND apply_type = 3) ) 
AND express_no IS NULL 
AND express_name IS NULL) 
ORDER BY apply_time DESC 
LIMIT 1,10

你可能感兴趣的:(MybatisPlus,Mysql)