> For the complete documentation index, see [llms.txt](https://docs.tibero.com/tmaxopensql.en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tibero.com/tmaxopensql.en/tmax-o2-extensions/reference-guides/sql-function/text-functions/instr.md).

# INSTR

## Syntax

```sql
INSTR(string, substring [, position [, occurrence]])
```

## Ovrview

`INSTR` is a function that searches for *substring* in *string*. The search operation works by sequentially comparing substrings of the same length as the target substring within the given string to check for a match. The search can proceed either forward or backward, with each new substring starting one character after (or before, in backward search) the previous one. If a matching substring is found, the function returns an integer indicating the position of the first character of the match. If no match is found, it returns 0.

#### Parameter

| Parameter         | Description                                                                                                                                                                                                                    |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| string, substring | Arbitrary operations that all return strings. If the string substr is not found within the string str, 0 is returned. The position value of the string starts from 1.                                                          |
| position          | Arbitrary operation that returns a non-zero integer value. (Default: 1) If position is given, search starts from the position of the string str. If position is negative, search starts from the end of the string str.        |
| occurrence        | Arbitrary operation that returns an integer value other than 0. (Default: 1) Given occurrence, returns the position of substr, which appears occurrence times within the search string. occurrence must be a positive integer. |

## **Example**

```sql
SELECT INSTR('ABCDEABCDEABCDE', 'CD');
 instr 
-------
     3
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tibero.com/tmaxopensql.en/tmax-o2-extensions/reference-guides/sql-function/text-functions/instr.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
