SELECT
                            origin.*,tmp.dbn_name_list
                        FROM
                            {ConstDatabaseMeta.DBMeta.DatabaseName}.{ConstDatabaseMeta.DBMeta.DDBMetaPolicy} AS origin,
                            (SELECT
                                MAX(id) AS id,name, JSON_ARRAYAGG(dbn_name) AS dbn_name_list
                            FROM
                                {ConstDatabaseMeta.DBMeta.DatabaseName}.{ConstDatabaseMeta.DBMeta.DDBMetaPolicy}
                            WHERE
                                ddb_ip='{ip}'
                                    AND
                                dbi_port={dbiPort}
                            GROUP BY
                                name) AS tmp
                        WHERE
                            origin.id = t.id

参考

https://www.jianshu.com/p/7f532985ff39

https://www.cnblogs.com/xzjf/p/8466858.html