Jump to content

count all member posts for each member


jasonc

Recommended Posts

i wish to get the total of posts from each member from the following database table

 

CREATE TABLE IF NOT EXISTS `posts` (
  `id` int(11) NOT NULL auto_increment,
  `submittedby` text NOT NULL,
  KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=786726 ;

 

i wish to have the results show the members name and the total posts.

 

how is this done please.

Link to comment
https://forums.phpfreaks.com/topic/171943-count-all-member-posts-for-each-member/
Share on other sites

I assume the id field is referring to another table and the id means id post of that table?

 

table2 = the table which contains the posts

table1 = this table you showed us

 

SELECT t2.*, count(t1.submittedby) s numberOfPosts from TABLE2 as t2 INNER JOIN table1 as t1 ON t2.id = t1.id GROUP BY t1.submittedby

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.