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.
idproperty. the second is an array. you need to loop through the array first to access each idIf it is possible that those arguments could return multiple values, the matched values are autowrapped as an array, in the order corresponding to the paths that produced them., see JSON_EXTRACT. See db-fiddle.