0
account_users
-----
id | primary_key

posts
-----
post_id | primary_key
author | foreign key to account_users.id

假设我有 2 张桌子。account_users 有用户。职位持有职位。

如何选择帖子计数(*)超过 5 个的所有用户?

4

2 回答 2

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
于 2012-06-30T05:52:07.247 回答
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
于 2012-06-30T06:00:14.993 回答