account_users
-----
id | primary_key
posts
-----
post_id | primary_key
author | foreign key to account_users.id
我们说我有2张桌子。 account_users有用户。帖子保留帖子。
如何选择帖子数量(*)超过5的所有用户?
答案 0 :(得分:0)
试试这个
SELECT au.*,p.*
FROM account_users au
INNER JOIN posts p
ON p.account_users.id = au.id
GROUP BY p.post_id
HAVING count(*) > 5
答案 1 :(得分:0)
@Timex
尝试以下查询。
Select au.ID from account_users au
inner join posts p on au.ID = p.author
Group By au.ID
having COUNT(p.post_id) > 5