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

# array_distinct

> Removes duplicate elements from an array.

Removes duplicate elements from an array.

## Syntax

```Haskell theme={null}
array_distinct(array)
```

## Parameters

`array`: the array from which you want to remove duplicate elements. Only the ARRAY data type is supported.

## Return value

Returns an array.

## Usage notes

* The elements of the array that is returned may be sorted in a different order than the elements of the array that you specify.

* The elements of the array that is returned are of the same data type as the elements of the array that you specify.

## Examples

In this section, the following table is used as an example:

```plaintext theme={null}
mysql> select * from test;

+------+---------------+

| c1   | c2            |

+------+---------------+

|    1 | [1,1,2]       |

|    2 | [1,null,null] |

|    3 | NULL          |

|    4 | [null]        |

+------+---------------+
```

Remove duplicate values from column `c2`.

```plaintext theme={null}
mysql> select c1, array_distinct(c2) from test;

+------+----------------------+

| c1   | array_distinct(`c2`) |

+------+----------------------+

|    1 | [2,1]                |

|    2 | [null,1]             |

|    3 | NULL                 |

|    4 | [null]               |

+------+----------------------+
```


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