我尝试使用不同的 mysql 连接/选择来获取至少有 25 个帖子或评论的所有用户。 有
users
id
valid
posts
id
user_id
comments
id
user_id
我试图让所有用户记录至少 25 条评论+帖子..
请帮忙!
最佳答案
尝试
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
关于mysql从3个表中计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11643833/