I'm using the JSON_EXTRACT with MYSQL and using this command:
SET @j = '{"id" : "1"}';
SELECT JSON_EXTRACT(@j, '$.id')
the result is
"1"
but, when I use
SET @j = '[{"id" : "1"}, {"id" : "2"}]';
SELECT JSON_EXTRACT(@j, '$.id')
the result is
NULL
I expected this result
"1"
"2"
Any sugestion? I want the list of ID'S from JSON.
try this:
SET @j = '[{"id" : "1"}, {"id" : "2"}]';
SELECT JSON_EXTRACT(@j,'$[*].id')
the result is:
["1", "2"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.