使用QueryWrapper追加条件
时间: 2023-10-14 17:03:45 浏览: 227
您可以使用QueryWrapper的and方法结合lambda表达式来追加条件。例如,如果您想要在构造器中插入自定义的SQL条件,可以按照以下方式进行操作:
```java
QueryWrapper<实体类> wqw = new QueryWrapper<>();
// 构造其他条件 ...
// 插入自定义 SQL
wqw.and(w -> {
w.last(" case when status = '1' then in_checkpoint = " + departId + " when status = '2' then out_checkpoint = " + departId + " end ");
});
```
通过使用and方法和lambda表达式,您可以在QueryWrapper中追加自定义的SQL条件。希望对您有帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [mybaties-plus使用QueryWrapper条件构造器的时候中间插入自定义sql](https://blog.csdn.net/weixin_43726137/article/details/129119621)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [QueryWrapper多条件嵌套查询](https://blog.csdn.net/weixin_51544010/article/details/115067678)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [javascript使用appendChild追加节点实例](https://download.csdn.net/download/weixin_38656400/13037848)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文