php - How to calculate sum of comments through specific id


I have two table one isblog which contains title and description while the second one iscomment which shows all comments related to specificblog_id.

blog_id is a primary key for theblog table while used as foreign key in thecomment table.




Suppose your blog id is 1

SELECT comments.blog_id AS blog_id, count(comments.blog_id) AS total_comment from comments where comments.blog_id = 1 group by comments.blog_id



You can use join, count and group by

select a.title, b.description, c.count(*) 
from table_one as a
inner join table_two as b on = b.table_one_id
group by a.title, b.description

People are also looking for solutions to the problem: php - TYPO3: Save and edit the first & last name of an FE user


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.