The syntax looks right to me, any help would be appreciated!
mysql> select fieldnames from tablename limit 5;
+--------------------------------------------------------+
| fieldnames |
+--------------------------------------------------------+
| {"example-field-1": "val2"} |
| {"example-field-2": "val1"} |
| {"example-field-1": "val1", "example-field-3": "val1"} |
| {"example-field-2": "val1"} |
| {"example-field-2": "val2"} |
+--------------------------------------------------------+
mysql> select JSON_EXTRACT(fieldnames, '$.example-field-1') from tablename;
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 17 in '$.example-field-1'.
MySQL 5.7.10
Can you try this advice from https://dev.mysql.com/doc/refman/5.7/en/json.html
As mentioned previously, path components that name keys must be quoted if the unquoted key name is not legal in path expressions. Let $ refer to this value.
select JSON_EXTRACT(fieldnames, '$."example-field-1"') from tablename;
NOTE
If you have more fields, you must quote each key not the whole path:
select JSON_EXTRACT(fieldnames, '$."field"."example-field-1"') from tablename;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With