Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两张桌子:主机和活动。每个活动都有一个 hostid。我想知道有多少主持人至少举办了三个活动 - 我想出了以下内容:
SELECT COUNT(*) FROM hosts,events WHERE hosts.id=events.host_id COUNT(hosts.id)>=3
但它给了我错误“无效使用组功能”。
我该如何解决?
试试这个:
SELECT hosts.id,count(*) FROM hosts JOIN events ON hosts.id=events.host_id GROUP BY hosts.id HAVING count(*)>=3