how can i use both in() and eq()
时间: 2024-03-17 11:46:50 浏览: 12
You can use both "in" and "eq" methods in Mybatis-plus lambda to create a complex SQL query. Here's an example:
Suppose you have an entity called "Product" with two properties: "category" and "price". You want to select all products that belong to the category "Electronics" and have a price of either $100 or $200.
You can use the "in" method to create a condition for the "price" property, and the "eq" method to create a condition for the "category" property. Here's how you can do it:
```
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Product::getCategory, "Electronics")
.in(Product::getPrice, 100, 200);
List<Product> products = productMapper.selectList(wrapper);
```
This will generate an SQL query like this:
```
SELECT * FROM product WHERE category = 'Electronics' AND price IN (100, 200);
```
This query will select all products from the "product" table that belong to the category "Electronics" and have a price of either $100 or $200.