mysql 一对多查询 组合成数组array列表形式
示例sql
SELECT h.cpu, d.instance_id, concat( '[', GROUP_CONCAT( JSON_OBJECT( 'size', d.size, 'id', d.instance_id ) SEPARATOR ',' ), ']' ) AS idisk FROM hosts h JOIN disks d ON h.instance_id = d.instance_id WHERE h.instance_id = 'i-uf60zsm04q873v1hcfp6';
查询结果
参考:https://stackoverflow.com/questions/69964344/get-data-from-one-to-many-relation-as-array
0顶
0 踩
共 0 条评论