0

如何从mysql 中的json代码中选择“风味”对象内的数组“1”

属性名称:设置

{"without":{"usd":{"new":"5","old":"8"},"weight":"5"},"color":{"2","3"},"flavor":{"1","2"}}

以及如何在“new”中的“usd”对象中获取一个数字,知道这些对象在第一个对象中并且它们是可变的,可能是[“without”或“long”或......]

属性名称:设置

{"without":{"usd":{"new":"5","old":"8"},"weight":"5"},"color":{"2","3"},"flavor":{["1","2"}}
{"long":{"usd":{"new":"2","old":"3"},"weight":"2"},"medium":{"usd":{"new":"3","old":"4"},"weight":"3"},"short":{"usd":{"new":"4","old":"5"},"weight":"4"}}
{"short":{"usd":{"new":"4","old":"5"},"weight":"2"},"color":{"1","2"}}

喜欢

without = 5
long = 2
short = 4
4

1 回答 1

1

我重建了数据格式,以便提取所需的数据

{"size":[{"id":1,"url":"without","weight":"5","price":{"usd":{"new":"5","old":"8"}}}],"color":[{"id":"2","url":"yellow"},{"id":"3","url":"green"}],"flavor":[{"id":"1","url":"berry"},{"id":"2","url":"strawberry"}]}

MYSQL

JSON_EXTRACT(details.settings, '$.color[*].url') LIKE '%yellow%'
于 2020-06-13T17:01:24.917 回答