---
title: startswith function
description: Learn the syntax of the startswith function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/startswith
---

# `startswith` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 10.4 LTS and above

Returns `true` if `expr` begins with `startExpr`.

## Syntax

```
startswith(expr, startExpr)
```

## Arguments

* `expr`: A `STRING` expression.
* `startExpr`: A `STRING` expression that is compared to the start of `str`.

## Returns

A `BOOLEAN`.

If `expr` or `startExpr` is `NULL`, the result is `NULL`.

If `startExpr` is the empty string or empty binary the result is `true`.

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 11.3 LTS and above

The function operates in `BINARY` mode if both arguments are `BINARY`.

## Examples

```sql
> SELECT startswith('SparkSQL', 'Spark');
 true

> SELECT startswith('SparkSQL', 'spark');
 false

> SELECT startswith('SparkSQL', NULL);
 NULL

> SELECT startswith(NULL, 'Spark');
 NULL

> SELECT startswith('SparkSQL', '');
 true
```

## Related

* [`contains` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/contains.md)
* [`endswith` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/endswith.md)
* [`substr` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/substr.md)
