Skip to content

Commit

Permalink
Merge pull request #187 from lorenzhs/patch-1
Browse files Browse the repository at this point in the history
Fix CONTAINS documentation
  • Loading branch information
arushi-firebolt authored Oct 26, 2023
2 parents 6ac8722 + 032965a commit 94ed64c
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions docs/sql-reference/functions-reference/contains.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
layout: default
title: CONTAINS
description: Reference material for CONTAINS function
description: Reference material for the CONTAINS function
parent: SQL functions
---

# CONTAINS

Returns `1` if a specified argument is present in the array, or `0` otherwise.
Returns whether the array passed as the first argument contains the value passed as the second argument.

## Syntax
{: .no_toc}
Expand All @@ -21,30 +21,28 @@ CONTAINS(<array>, <value>)
| Parameter | Description | Supported input types |
| :--------- | :------------------------------------------------ | :--------|
| `<array>` | The array to be checked for the given element. | `ARRAY` |
| `<value>` | The element to be searched for within the array | Any integer that corresponds to an element in the array |
| `<value>` | The element to be searched for within the array | The array elements' type |

## Return Types
* Returns `1` if the element to be searched in present in the array
* Returns `0` if the element is not present in the array
## Return Type
`BOOLEAN`
* Returns `true` if the element to be searched is present in the array
* Returns `false` if the element is not present in the array

## Example
{: .no_toc}

```sql
SELECT
CONTAINS([ 'sabrina21', 'rileyjon', 'ywilson', 'danielle53'], 'danielle53') AS players;
CONTAINS(['sabrina21', 'rileyjon', 'ywilson', 'danielle53'], 'danielle53');
```

**Returns**: `1`
`1` is returned as "danielle53" is part of the `players` array.
**Returns**: `true` as "danielle53" is part of the array.

`CONTAINS` returns a `0` result when single character or substring matches only part of a longer string.
`CONTAINS` returns `false` when the value is not contained in the array:

```sql
SELECT
CONTAINS([ 'sabrina21', 'rileyjon', 'ywilson'] , 'danielle53') AS players;
CONTAINS(['sabrina21', 'rileyjon', 'ywilson'] , 'danielle53');
```

**Returns**: `0`

`0` is returned as "danielle53" is not part of the `players` array.
**Returns**: `false` as "danielle53" is not part of the array.

0 comments on commit 94ed64c

Please sign in to comment.