美文网首页
mysql 问题

mysql 问题

作者: 领带衬有黄金 | 来源:发表于2020-09-04 14:30 被阅读0次
    zone_assign_infos = ZoneConfigInfo.query.outerjoin(
            GameConfigMap,
            ZoneConfigInfo.id == GameConfigMap.config_file_id
        ).with_entities(
            ZoneConfigInfo.id,
            ZoneConfigInfo.file_type,
            db.func.count(GameConfigMap.id).label('num')
        ).group_by(ZoneConfigInfo.id).order_by(desc('num'))
        ret = [{'id': i[0], 'name': i[1], 'num': i[2]} for i in zone_assign_infos]
        return {'data': ret}
    
    
    SELECT
        qy_zone_config_file_info.id AS qy_zone_config_file_info_id,
        qy_zone_config_file_info.file_type AS qy_zone_config_file_info_file_type,
        count( qy_game_config_map.id ) AS num 
    FROM
        qy_zone_config_file_info
        LEFT OUTER JOIN qy_game_config_map ON qy_zone_config_file_info.id = qy_game_config_map.config_file_id 
    GROUP BY
        qy_zone_config_file_info.id
    ORDER BY
        num DESC
    
    

    相关文章

      网友评论

          本文标题:mysql 问题

          本文链接:https://www.haomeiwen.com/subject/qfvzsktx.html