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.
私は次のテーブルを持っています:
fss_post(post_id,text) fss_comment(idComment, post_id, text)
この投稿の合計コメント数を含む各 post_id の行を結果として返すクエリを作成することは可能ですか?
例:
post_id comment_count 101010 5 101011 0
などなど… ありがとうございます。
select p.post_id,count(*) 'comment_count' from fss_post p left join fss_comment c on p.post_id = c.post_id group by p.post_id
これを試してください: コメント GROUP BY post_id; から post_id, COUNT(comment_id) を選択します。