- Categories:
MAP_CONTAINS_KEY¶
Determines whether the specified MAP contains the specified key.
Syntax¶
Arguments¶
keyThe key to find.
mapThe map to be searched.
Returns¶
Returns TRUE if the specified map contains the specified key.
Returns FALSE if the specified map doesn’t contain the specified key.
Usage notes¶
The type of the key expression must match the type of the map’s key. If the type is VARCHAR, the types can be different lengths.
For NULL input, the output is NULL.
Examples¶
The function searches for the k1 key and finds it in the map:
The function searches for the k1 key and doesn’t find it in the map:
A SELECT statement passes in a key that uses a different type than the key in the map:
Create a temporary table that contains MAP values:
Query the table to show the data:
Determine whether the map in the attrs column contains the key in the ins_key column:
The output shows the following:
The map in the
attrscolumn in row1doesn’t contain the key (material) in theins_keycolumn.The map in the
attrscolumn in row2contains the key (brand) in theins_keycolumn.