MySQL JSON Keys
Continuing from the last entry on using MySQL's new JSON data type , let us take a look at the keys in our sample database. Use JSON_KEYS to get a lit of the Keys withing the document. mysql> SELECT JSON_KEYS(info) FROM stooge; +-----------------+ | json_keys(info) | +-----------------+ | ["job", "name"] | | ["job", "name"] | | ["job", "name"] | | ["job", "name"] | +-----------------+ 4 rows in set (0.00 sec) So how many records have a 'job' key? mysql> select JSON_CONTAINS_PATH(info,'all','$.job') from stooge; +----------------------------------------+ | JSON_CONTAINS_PATH(info,'all','$.job') | +----------------------------------------+ | 1 | | 1 | | 1 | | 1 | +----------------------------------------+ 4 row...