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

# element_at

> Returns the value for the specified key from a key-value pair of a map.

Returns the value for the specified key from a key-value pair of a map. If any input parameter is NULL or if the key does not exist in the map, the result is NULL.

If you want to retrieve an element from an array, see [element\_at](/documents/4.2/sql-reference/sql-functions/array-functions/element_at.md).

This function is supported from v3.0 onwards.

## Syntax

```Haskell theme={null}
element_at(any_map, any_key)
```

## Parameters

* `any_map`: a MAP expression from which to retrieve values.
* `any_key`: a key in the map.

## Return value

If `any_key` exists in `any_map`, the value corresponding to the key will be returned. Otherwise, NULL is returned.

## Examples

```plain text theme={null}
mysql> select element_at(map{1:3,2:4},1);
+-----------------+
| map{1:3,2:4}[1] |
+-----------------+
|               3 |
+-----------------+

mysql> select element_at(map{1:3,2:4},3);
+-----------------+
| map{1:3,2:4}[3] |
+-----------------+
|            NULL |
+-----------------+

mysql> select element_at(map{'a':1,'b':2},'a');
+-----------------------+
| map{'a':1,'b':2}['a'] |
+-----------------------+
|                     1 |
+-----------------------+
```

## keywords

ELEMENT\_AT, MAP


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