find_in_set()
时间: 2023-08-15 15:14:08 浏览: 48
Oracle中没有find_in_set函数,但可以使用REGEXP_LIKE函数来实现类似的功能。例如:
SELECT * FROM table_name WHERE REGEXP_LIKE(column_name, 'value1|value2|value3');
这将返回column_name中包含value1、value2或value3的所有行。
相关问题
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?
find_in_set
`FIND_IN_SET` 是 MySQL 中的一个函数,用于在一个逗号分隔的字符串列表中查找一个特定的值,并返回其在列表中的位置。它的语法如下:
```
FIND_IN_SET(search_value, target_string)
```
其中,`search_value` 是要查找的值,`target_string` 是逗号分隔的字符串列表。如果找到了 `search_value`,则返回其在列表中的位置,否则返回 0。例如:
```
SELECT FIND_IN_SET('apple', 'apple,banana,orange') as position; -- 返回 1
SELECT FIND_IN_SET('peach', 'apple,banana,orange') as position; -- 返回 0
```
需要注意的是,`FIND_IN_SET` 函数只能用于逗号分隔的字符串列表,不能用于其他类型的数据列表。如果你想在其他类型的数据列表中查找特定的值,可以考虑使用 `IN` 关键字或 `FIND_IN_SET` 的替代函数。