有时 我们需要统计的每个分类的分享数量的时候,用到了关联查询
mysql语句
select a.user_id,u.uname,a.share_type,count(a.share_type)
FROM
`h_share_info` as a,
`h_users` as u
WHERE
a.user_id = u.user_id
GROUP BY
a.user_id,a.share_type//先按照user_id,在按照类型排序
有时 我们需要统计的每个分类的分享数量的时候,用到了关联查询
mysql语句
select a.user_id,u.uname,a.share_type,count(a.share_type)
FROM
`h_share_info` as a,
`h_users` as u
WHERE
a.user_id = u.user_id
GROUP BY
a.user_id,a.share_type//先按照user_id,在按照类型排序