I have the following table def:
`CREATE TABLE `TestInfo` (
`Info` json DEFAULT NULL
) ;
`
Am inserting two rows with json values.
INSERT INTO `TestInfo` (`Info`)
VALUES
('{
"statusCode": 200,
"result": {
"summary": {
"area": 0.0009904206008286565
}
}
} '
);
INSERT INTO `TestInfo` (`Info`)
VALUES
(
'{
"statusCode": 200,
"result": {
"summary": {
"area": 0.0009904206008286565,
"realty-society": {
"price-min": {
"property": "price-min",
"min": 110000.00000000001,
"max": 150000000,
"average": 31184468.085106384,
"sum": 1465670000
}
}
}
}
} '
);
When I run the query:
SELECT JSON_EXTRACT(Info, '$.result.summary')
FROM TestInfo ;
it returns the 2 rows. This is fine. But when I run the same query with double quotes around the path like this:
SELECT JSON_EXTRACT(Info, '$."result.summary"')
FROM TestInfo;
it returns the 2 rows (with the single column) as NULLs.
Ultimately I need to use double quotes for keys that have a hyphen (dash) in them. I am using MySQL 5.7 on AWS. Pl help.