find_in_set
时间: 2023-09-03 08:14:53 浏览: 37
`FIND_IN_SET` 是MySQL数据库中的一种函数,用于在逗号分隔的字符串中查找指定的值。它的语法是 `FIND_IN_SET(str, strlist)`,其中 `str` 是要查找的值,`strlist` 是被查找的逗号分隔的字符串。该函数返回 `str` 在 `strlist` 中的位置,如果不存在则返回0。例如,`FIND_IN_SET('apple', 'banana,apple,orange')` 返回值为2,因为'apple'在逗号分隔的字符串中是第二个元素。
相关问题
FIND_IN_SET
`FIND_IN_SET` is a MySQL function that is used to search for a value within a comma-separated list. It returns the position of the value within the list, or 0 if it is not found. The syntax for using `FIND_IN_SET` is as follows:
```sql
FIND_IN_SET(value, list)
```
Here, `value` is the value to search for, and `list` is the comma-separated list of values.
For example, `FIND_IN_SET('apple', 'apple,banana,grape')` will return 1, as 'apple' is the first value in the list. On the other hand, `FIND_IN_SET('orange', 'apple,banana,grape')` will return 0, as 'orange' is not present in the list.
Is there anything else you would like to know?
SELECT * FROM t01_di_cust_info where 1=1 and ( FIND_IN_SET(1,KEY_INDUSTRIAL_CHAIN) AND FIND_IN_SET(3,KEY_INDUSTRIAL_CHAIN) )
根据提供的引用内容,SELECT语句中的FIND_IN_SET函数用于在字符串列表中查找指定的值。在这个例子中,FIND_IN_SET函数用于在KEY_INDUSTRIAL_CHAIN字段的值中查找1和3。如果找到了这两个值,则返回true,否则返回false。
以下是一个示例SELECT语句的演示:
```sql
SELECT * FROM t01_di_cust_info
WHERE 1=1
AND (FIND_IN_SET(1, KEY_INDUSTRIAL_CHAIN) AND FIND_IN_SET(3, KEY_INDUSTRIAL_CHAIN))
```
这个SELECT语句将返回t01_di_cust_info表中满足以下条件的所有行:
- 1和3都在KEY_INDUSTRIAL_CHAIN字段的值中出现。
阅读全文