1

我尝试玩不同的 mysql joins/selects 来获取至少有 25 个帖子或评论的所有用户。有

users
  id
  valid

posts
  id
  user_id

comments
  id
  user_id

在那里,我试图让所有用户记录至少 25 条评论+帖子..

请帮忙!

4

1 回答 1

3

尝试

select u.* 
from users u
left outer join posts p on p.user_id = u.id
left outer join comments c on c.user_id = u.id
group by u.id
having (count(p.id) + count(c.id)) >= 25
于 2012-07-25T06:26:27.577 回答