Jump to content


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


Count rows sort of problem

Recommended Posts

Well, I know how to count the number of rows a query returns, but Im looking for something a little more in depth and I can't figure it out, nor do I know exactly what to serach for.

Here is what I'm trying to do, I hope somebody has done this before, or can help.

Say I have a bunch of rows in a table, these are news posts by many users. I want to do a query that says how many posts each user has.

My table looks like,

ID | Username | Date | Data

1 | Bob | Today | Testing
2 | Bob | Today | Testing
3 | Bob | Today | Testing
4 | Bob | Today | Testing
5 | Bob | Today | Testing
6 | Tom | Today | Testing
7 | Tom | Today | Testing
8 | Tom | Today | Testing

Thats fake of course, but that is a good example. I want to say: Bob has 5 posts and Tom has 3. I can use a count of rows but that will return 8, and there are more users then those 2 and names cannot be hardcoded in, so a WHERE username= wont work.

I hope somebody can help, thanks for looking! :-)

Share this post

Link to post
Share on other sites


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.