> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# INSTR

> Returns a substring position.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

NULL string/search, or a supplied NULL start/occurrence operand, returns NULL. Omitted start and occurrence default to one.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
instr(value, search [, start [, occurrence]])
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING | Yes | Haystack. |
| search | STRING | Yes | Needle. |
| start | INTEGER | No | Positive starting character position. Positive values (at least 1) for the supported forward-search contract. Default: 1. |
| occurrence | INTEGER | No | Positive occurrence number. Positive values (at least 1) for the supported forward-search contract. Default: 1. |

## Returns

* Type: BIGINT; query tools may report INTEGER
* Possible values: One-based position or zero when absent.
* NULL behavior: NULL string/search, or a supplied NULL start/occurrence operand, returns NULL. Omitted start and occurrence default to one.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* INSTR uses haystack, needle; LOCATE uses needle, haystack.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT instr('Hello', 'll') AS "value";
```

| value |
| - |
| 3 |

### Find the first occurrence

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT instr('banana', 'an') AS first_match, instr('banana', 'xy') AS missing;
```

| first\_match | missing |
| - | - |
| 2 | 0 |

## Limitations

* The position is returned as BIGINT, even when query tools report INTEGER.
* Use start and occurrence values of at least 1. Zero or negative values can fail or give unexpected results. For non-ASCII text, a start position beyond the string’s length can restart the search at the beginning.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.