|
-
Feb 16th, 2013, 07:32 PM
#1
Thread Starter
Fanatic Member
Counting User Post Count ?
I didn't think this was going to be so tricky. Basically I have two tables in my mysql database (user, comments). Each table has the users id. I simply just want to count how many posts/comments each user has and then place it in the user table, in a field called 'postnumber'. Can anyone guide me in the right direction on how I can achieve this ? I've searched the net but haven't found any useful information.
Thanks in Advance !!
-
Feb 17th, 2013, 09:43 AM
#2
Re: Counting User Post Count ?
This would get the user_name with post_count.
Code:
SELECT DISTINCT `user_name`, (SELECT count(*) FROM `tblComments` WHERE `tblComments`.`user_id`=`tblUsers`.`user_id`) AS `post_count` FROM `tblUsers`
Test it out.
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|