mybatisplus find_in_set
时间: 2023-08-15 07:13:49 浏览: 110
mybatis_plus
MyBatis Plus doesn't have a built-in function for `FIND_IN_SET` like MySQL does. However, you can achieve similar functionality using the `Sqls` class provided by MyBatis Plus.
Here's an example of how you can use the `Sqls` class to simulate the `FIND_IN_SET` function in MyBatis Plus:
```java
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
...
QueryWrapper<Entity> queryWrapper = new QueryWrapper<>();
queryWrapper.apply(SqlUtils.format("FIND_IN_SET({0}, column_name) > 0", value));
List<Entity> result = entityMapper.selectList(queryWrapper);
```
In the above example, `column_name` is the name of the column you want to search in, and `value` is the value you want to find within the set.
The `SqlUtils.format` method helps format the SQL statement with the desired parameters.
Please note that this approach may not be as efficient as using the native `FIND_IN_SET` function in MySQL, as it requires additional processing in Java.
阅读全文