mybatis INSTR
时间: 2023-11-07 13:49:24 浏览: 112
INSTR is a built-in function in MyBatis that is used to find the position of a substring within a string. It takes two arguments: the string to search within and the substring to search for.
For example, if you have a column named 'description' in your database table and you want to find all records that contain the word 'apple', you can use the INSTR function in your MyBatis query like this:
```xml
<select id="findProductsContaining" resultType="Product">
SELECT * FROM products
WHERE INSTR(description, 'apple') > 0
</select>
```
This query will return all products where the 'description' column contains the word 'apple'. The INSTR function will return the position of 'apple' within the 'description' string, and if it is greater than 0, it means the substring was found.
Note that the INSTR function is specific to the database you are using with MyBatis. The above example assumes a MySQL database, but the syntax may vary for other databases.
阅读全文