account_users
-----
id | primary_key
posts
-----
post_id | primary_key
author | foreign key to account_users.id
假设我有 2 张桌子。account_users 有用户。职位持有职位。
如何选择帖子计数(*)超过 5 个的所有用户?
试试这个
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
@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