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.
「id」と「user_id」という名前の2つの列を持つ写真テーブルがあります。明らかに、1 人のユーザーが多くの写真を持つことができます。各ユーザーの写真数を取得できるクエリを実行したいと思います。
どんな助けでも大歓迎です。
select user_id, count(*) as photo_count from photos group by user_id
使用する:
SELECT t.user_id, COUNT(*) AS photo_count FROM PHOTOS GROUP BY t.user_id