Jump to content

returning a count from a table but not including where one field is the same


shadiadiph

Recommended Posts

Slight query I have a database that has my online users in it how can i add something to it where the 'username' field is thesame for example

 

$getusers='';
$getusers="SELECT * FROM `tblonline` WHERE `usertype`='user'";

 

I need something to filter out if the user has opened two browsers and is logged in for example 'username'='john' might appear twice in the table but I only want to count it once with the num_rows query

you can group your results by username, then count them in the way you prefer

 


$getusers="SELECT * FROM `tblonline` WHERE `usertype`='user' GROUP BY `username` ";

 

it will give you one result per-user logged

Archived

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

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