Jump to content

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! :-)
Link to comment
https://forums.phpfreaks.com/topic/9165-count-rows-sort-of-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.