Jump to content

need help with correct GROUP BY (might be something else) :)


Recommended Posts

I have a simple code that should count my online members for a team:

 

$online_members = mysql_query ("SELECT count(vtp_tracking.credit_members_id) as members FROM vtp_tracking WHERE action_date>date_sub(NOW(),interval 10 minute) AND teamid=".$rsget_team_id['team_id']." GROUP BY credit_members_id")
  or die(mysql_error()); 
$rs_online_members = mysql_fetch_array( $online_members );

 

my problem is getting the actual count, as I get the wrong amount of online members. Basicaly I count the unique member id where the team id is the same as the user (teamid=".$rsget_team_id['team_id']." ).

 

What should I group by to count the numbers of different "vtp_tracking.credit_members_id" ?

From what I gather, you are probably wanting to group by the teamid. But, since you're already filtering out all the other teams except the one you want, you don't need the GROUP BY clause.

 

That is what you want, right? The number of online members from a certain team?

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.