mysql 查询json字段

表table_user 字段 id,info(json);

{
    "id": 111,
    "name": "李白",
    "info": {
        "aliasNames": [
            {
                "name": "李酒鬼"
            },
            {
                "name": "诗仙"
            }
        ]
    }
}

SELECT id,REPLACE(JSON_EXTRACT(info,'$.name'),'"','') as a ,REPLACE(JSON_EXTRACT(JSON_EXTRACT(info,'$.aliasNames'),'$[*].name'),'"',',') AS actors  FROM table_user WHERE id = 4498657

执行结果

111    李白    [,李酒鬼,诗仙]

你可能感兴趣的:(数据库,sql)