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

# element_at

> 获取 Map 中指定键对应的值。

获取 Map 中指定键 (Key) 对应的值 (Value)。如果输入值为 NULL 或指定的 Key 不存在，则返回 NULL。

如果您想从 Array 数据中获取指定位置的元素，参见 Array 函数中的 [element\_at](/documents/cn/4.2/sql-reference/sql-functions/array-functions/element_at.md)。

该函数从 3.0 版本开始支持。

## 语法

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

## 参数说明

* `any_map`: Map 表达式。
* `key`: 指定的 key。如果 `key` 不存在，返回 NULL。

## 返回值说明

返回 `key` 对应的 Value 值。

## 示例

```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.