在嵌套的JSON中转换mysql“ group by语句”

时间:2019-12-02 17:03:36

标签: mysql sql json

我想执行查询mysql并将结果转换为

之类的json

这是我正在使用的查询:

listin %>% group_by(title, Action_updated=="Registration") %>% summarise(Count = n()) %>% ungroup() %>% mutate(Action_updated = "InsinuatedRegistered") 

这就是我想要的结构,可以通过任何方式实现

期望的JSON:

SELECT
    c.state_id,
    s.name,
    u.city_id,
    c.name,
    COUNT(u.id)
FROM
    user u
        INNER JOIN 
    cities c ON c.id = u.city_id
        INNER JOIN 
    states s ON s.id = c.state_id
    GROUP BY c.state_id, u.city_id;

我有mysql版本5.7

0 个答案:

没有答案