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.
ホストとイベントの2つのテーブルがあります。すべてのイベントにはhostidがあります。少なくとも3つのイベントが発生しているホストの数を知りたいのですが、次のことを思いつきました。
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