Answer the question
In order to leave comments, you need to log in
How to get data from JSON by string length?
Hello to all!
Please tell me how to make a selection from JSON? JSON is the following:
{"@class": "Name.Of.Class, "member": "666", "Members": [{"values": ["111", "222", "333"], "Type": "BIG", "Number": "111111", "Count": 50, "BIGUnit": 50}, {"values": ["111", "222", "333"],"BIGType":"BIG","Number": "111", "Count": 10, "BIGUnit": 10}, {"values": ["111", "222", "333"], "BIGType": "BIG", "Number": "222", "Count": 10, "BIGUnit": 10}, {"values": ["111", "222", "333"], "BIGType": "BIG","Number": "333", "Count": 10, "BIGUnit": 10}, {"values": ["111", "222", "333"], "BIGType": "BIG", "Number": "333333", "Count": 10, "BIGUnit": 10}], "ID": "07"}
SELECT
c_date AS cd,
JSON_UNQUOTE(JSON_EXTRACT(jsonc,"$.Members[*].Number")) AS rep,
id AS did
FROM reports
WHERE length(JSON_UNQUOTE(JSON_EXTRACT(jsonc,"$.Members[*].Number"))) > 3;
Answer the question
In order to leave comments, you need to log in
SELECT cte1.cdate AS cd,
JSON_UNQUOTE(JSON_EXTRACT(cte1.rep, CONCAT('$[', cte2.num, ']'))) AS rep,
cte1.id AS did
FROM ( SELECT cdate,
id,
JSON_EXTRACT(jsonc,"$.Members[*].Number") AS rep
FROM reports ) cte1,
( SELECT help_keyword_id num
FROM mysql.help_keyword ) cte2
HAVING LENGTH(rep) > 3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question