php - MySQL count unique rows based on multiple factors -


i need find unique rows based on unique ip , result sorted users in single query.

i trying way

$query="select  count(distinct `userip`) `count`, `userid` `userid` `tablename`  (`date` >= unix_timestamp(curdate())) group `userid`"; $result = mysqli_query($connection, $query) or trigger_error(mysqli_error($connection), e_user_error);   $row = mysqli_fetch_assoc($result); print_r($row); 

this gives me result last user as

array ( [count] => xxx [userid] => last_user); 

i need result every user in single query as

array (      array ( [count] => xxx [userid] => first_user);     .     .     array ( [count] => xxx[userid] => last_user); ) 

please see if can done, , suggest way it. thanks

edit

thanks answers, solution working checking query on row instead of result.

i think should use group on both columns userip , userid columns. see if below query works you.

select count( `userip`) `count`, `userid` `userid` `tablename` (`date` >= unix_timestamp(curdate())) group userid,userip;  

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -