'How to extract fields from mysql json field order by value
| id | json_field |
| 1 | {"a": 1, "b" : 3, "c": 2, "d": -1} |
I want to get the two fields which have the smallest values(I not sure I am expressing clearly), in this case is a and d.
Senario:
given a field, I wanna check if this field is among the two fields which have smallest values in json_field, and fetch all results match this condition.
I wanna implement it by: Sort json by value, convert it's fields to an array, and then get the last/first two one. After I have searched around, I cannot find a way to sort json field by value. I am stuck.
BTW, I am using MySQL5.7.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
