I canโt think clearly at the moment, I want to return counts by station_id, an example output would be:
station 1 has 3 fb messages, 6 related messages, 5 email messages station 2 has 3 fb messages, 6 related messages, 5 email messages
So I need to group by station ID, my table structure
CREATE TABLE IF NOT EXISTS `posts` ( `post_id` bigint(11) NOT NULL auto_increment, `station_id` varchar(25) NOT NULL, `user_id` varchar(25) NOT NULL, `dated` datetime NOT NULL, `type` enum('fb','linkedin','email') NOT NULL, PRIMARY KEY (`post_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=x ;
The query that I have so far returns station 0 as having 2 attached messages when it has one (2 in db tho)
SELECT Station_id, (select count(*) FROM posts WHERE type = 'linkedin') AS linkedin_count, (select count(*) FROM posts WHERE type = 'fb') AS fb_count, (select count(*) FROM posts WHERE type = 'email') AS email_count FROM `posts` GROUP BY station_id;
source share