explain find_in_set
时间: 2023-09-08 13:14:52 浏览: 121
mysql通过find_in_set()函数实现where in()顺序排序
The `FIND_IN_SET` function is a MySQL function that searches for a value within a comma-separated list of values. It takes two arguments: the value to search for and the comma-separated list to search within.
The function returns the position of the value within the list if found, or 0 if not found. The position is determined by the order in which the values appear in the list.
Here's an example to illustrate its usage:
```
SELECT FIND_IN_SET('apple', 'apple,banana,grape');
```
In this example, the value 'apple' is searched within the list 'apple,banana,grape'. Since 'apple' is the first value in the list, the function will return 1.
Please note that the `FIND_IN_SET` function is case-sensitive, meaning it treats uppercase and lowercase letters as distinct values.
阅读全文