mysql json配列インデックスindexダイナミック

1133 ワード

必要:
select jsonArray[index],index from table;

エラー・デモンストレーション
select jsonArray->"$[index]",index from table;
select json_extract(jsonArray, "$[index]"),index from table;

原理&正しい方法
文字列結合関数CONCATでjson_を生成できます.extractの2番目のパラメータ
select json_extract(jsonArray,CONCAT('$[',`index`,']')),index from table;