# starts_with

> 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: starts_with
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/starts-with
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/starts-with.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/string-functions/starts-with.adoc
description: The `starts_with()` function determines whether the first argument starts with a specified string in the second argument or not.
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/starts-with.md -->

The `starts_with()` function determines whether the first argument starts with a specified string in the second argument or not.

```sql
STARTS_WITH(first_argument, 'second_argument')
```

-   `first_argument`: The search reference. Can be a string or a column name.

-   `second_argument`: The specified argument, which will have the search keywords.


The input type will be `STRING`, and the return type is `bool`, shown as `true` or `false`.

Special case:

-   Returns `NULL` for the `NULL` record.

-   Returns `true` for any non-`NULL` string when the `second_argument` is an empty string (`''`).


## [](#examples)Examples

### [](#starts_with-function-using-column)`starts_with()` function using column

Consider a table with the title **petsData**.

```sql
CREATE TABLE petsData (
  petid int,
  petname text,
  species text,
  breed text,
  sex text,
  age int
);
INSERT INTO petsData
    (petid, petname, species, breed, sex, age)
VALUES
    (2021001,'Bartholomeow','cat','persian','m',2),
    (2021004,'Jack','dog','boston terrier','m',1),
    (2022001,'Jesse','hamster','dzungarian','m',1),
    (2022010,'Bella','dog','dobberman','f',3),
    (2022011,'June','cat','american shorthair','f',2);
```

```sql
SELECT * FROM petsData;
```

This query shows the table:

```sql
+----------+--------------+----------+---------------------+------+-----+
| petid    | petname      | species  | breed               | sex  | age |
+----------+--------------+----------+---------------------+------+-----+
| 2021001  | Bartholomeow | cat      | persian             | m    | 2   |
| 2021004  | Jack         | dog      | boston terrier      | m    | 1   |
| 2022001  | Jesse        | hamster  | dzungarian          | m    | 1   |
| 2022010  | Bella        | dog      | dobberman           | f    | 3   |
| 2022011  | June         | cat      | american shorthair  | f    | 2   |
+----------+--------------+----------+---------------------+------+-----+
```

From the table, this query retrieves the values of the **petname** column that start with "J":

```sql
SELECT petname, STARTS_WITH(petname, 'J') FROM petsData;
```

This returns `true` to the pet with a pet starting with the letter J. Otherwise, `false`.

```sql
+--------------+---------------+
|   petname     | starts_with  |
+---------------+--------------+
| Bartholomeow  | false        |
| Jack          | true         |
| Jesse         | true         |
| Bella         | false        |
| June          | true         |
+---------------+--------------+
```

### [](#starts_with-function-with-an-empty-second-argument)`starts_with()` function with an empty second argument

The **petsData** table has a row with an empty string (`''`) in the breed column.

```sql
CREATE TABLE petsData (
  petid int,
  petname text,
  species text,
  breed text,
  sex text,
  age int
);
INSERT INTO petsData
    (petid, petname, species, breed, sex, age)
VALUES
    (2021001,'Bartholomeow','cat','persian','m',2),
    (2021004,'Jack','dog','boston terrier','m',1),
    (2022001,'Jesse','hamster','dzungarian','m',1),
    (2022010,'Bella','dog','dobberman','f',3),
    (2022011,'June','cat','american shorthair','f',2),
    (2022012,'Phoebe','gold fish','','f',1);
```

```sql
SELECT * FROM petsData;
```

```sql
+----------+--------------+------------+---------------------+------+------+
| petid    | petname      | species    | breed               | sex  | age  |
+----------+--------------+------------+---------------------+------+------+
| 2021001  | Bartholomeow | cat        | persian             | m    | 2    |
| 2021004  | Jack         | dog        | boston terrier      | m    | 1    |
| 2022001  | Jesse        | hamster    | dzungarian          | m    | 1    |
| 2022010  | Bella        | dog        | dobberman           | f    | 3    |
| 2022011  | June         | cat        | american shorthair  | f    | 2    |
| 2022012  | Phoebe       | gold fish  |                     | f    | 1    |
+----------+--------------+------------+---------------------+------+------+
```

Run the `starts_with` function with an empty string (`''`) as the `second_argument`:

```sql
SELECT breed, STARTS_WITH(breed, '') FROM petsData;
```

This result shows that `starts_with` returns `true` for all records, including the row with an empty string for `breed`:

```sql
+---------------------+--------------+
| breed               | starts_with  |
+---------------------+--------------+
| persian             | true         |
| boston terrier      | true         |
| dzungarian          | true         |
| dobberman           | true         |
| american shorthair  | true         |
|                     | true         |
+---------------------+--------------+
```