MySQL 5.7

There is a table:

INSERT INTO `tj10` (`id`, `a`) VALUES (1, '{"3": 10, "8": 17}'), (2, '{"3": 11, "5": 55, "0": 44}'), (3, '{"3": 12, "7": 55, "5": 57, "0": 44}'); 

How to select from the table all records that have the key "5" in the column "a"?

How to extract the value of the key "5" in the column "a"?

The keys may be in a different order.

a->'$.5' gives an error, and a->"$[5]" takes the value of the 6th key in order

  • You can select all entries by adding a LIKE '% "5":%' to the WHERE clause, but this is not the right decision. - Konstantin

0