# POSITION

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: POSITION
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/string-functions/position
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/string-functions/position.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/string-functions/position.adoc
description: The `POSITION` function returns the position of the first occurrence of a substring in a string.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/position.md -->

The `POSITION` function returns the position of the first occurrence of a substring in a string. It works the same as [`strpos()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/strpos/), but it has slightly different syntax.

## [](#syntax)Syntax

The syntax for this function is:

```sql
POSITION(substring IN string)
```

The position of the substring within the string starts from 1. If the substring is not found, it returns 0.

## [](#examples)Examples

### [](#example-1)Example 1

This query looks for the position of the substring `world` within the string `Hello, world!`.

```sql
SELECT POSITION('world' IN 'Hello, world!');
```

The result would be the starting position of the substring `world`, which is 7.

```sql
position
----------
        7
```

### [](#example-2)Example 2

The query looks for the position of the substring `123` within the string `1a2b3c`.

```sql
SELECT POSITION('123' IN '1a2b3c');
```

The substring `123` does not appear contiguously in `1a2b3c`, so the result is 0.

```sql
position
----------
        0
```

### [](#example-3)Example 3

The query tries to find the position of the substring `abc` within the string `xyz`.

```sql
SELECT POSITION('abc' IN 'xyz');
```

`abc` is not found in `xyz`, the result would be 0.

```sql
position
----------
        0
```

### [](#example-4)Example 4

This query searches for the position of the substring `cde` within the string `cde`.

```sql
SELECT POSITION('cde' IN 'cde');
```

`cde` is the entire string, the result would be 1.

```sql
position
----------
        1
```