MySQL (GROUP BY)

Seonmi Choi·2021년 2월 8일
0

COUNT() function with group by

SELECT colum,COUNT(*)
FROM table      
GROUP BY grouping colum;

example:

 `SELECT COUNT(content.id) as ContentCount 
  FROM content
  JOIN user ON user.id = content.userId 
  WHERE user.name = 'duRiCha'`;
  `SELECT user.name AS name, COUNT(content.body) AS ContentCount 
   FROM content
   RIGHT JOIN user ON user.id = content.userId
   GROUP BY name`;
profile
I am not afraid of learning!

0개의 댓글

관련 채용 정보