select instr
时间: 2023-08-18 10:13:07 浏览: 107
`INSTR` is a function commonly used in SQL queries to find the starting position of a substring within a string. It returns the position of the first occurrence of the substring within the string, or 0 if the substring is not found. The syntax for the `INSTR` function is as follows:
```
INSTR(string, substring, [start_position, [occurrence]])
```
- `string`: The string in which you want to search for the substring.
- `substring`: The substring you want to find within the string.
- `start_position` (optional): The position in the string where the search should start. If not specified, the search starts from the beginning of the string.
- `occurrence` (optional): The occurrence of the substring to find. If not specified, it defaults to 1.
Here's an example usage:
```sql
SELECT INSTR('Hello, World', 'World') AS position;
```
This query will return the value `8`, as the substring 'World' starts at position 8 within the string 'Hello, World'.
阅读全文