您需要使用GROUP BY两次,首先从下面的(user_id,status)开始获取计数,然后从连接的表到concat的user_id:
SELECt users.name, GROUP_CONCAt( CONCAt(f.status, ',', f.cnt) SEPARATOR '|' )FROM users JOIN( SELECt user_id, status, count(id) AS cnt FROM application_follows GROUP BY user_id, status ) fON f.user_id = users.idGROUP BY users.id
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)