[eluser]Lpeek[/eluser]
Hey! I'm trying to select data from a table, where the uid, ip, and user_agent are distinct. Yet regardless of what I try I can only seem to count the total occurrences of uid.
My table has 30 entries with the same uid, of those, only 3 have a different ip and user_agent. So I'm trying to return 3, yet I always get 30.
This is my latest attempt:
Code:
$this->db->distinct();
$this->db->select(array('uid', 'ip', 'user_agent'));
$this->db->select_sum('uid', 'views');
$this->db->where('datetime >',$dbDateTime);
$this->db->group_by('uid');
$query = $this->db->get('poster_views');
I've also tried grouping by the three fields, but this returns multiple rows of the same uid, so instead of 1 row with 'views' as 3, I get 3 rows each with views such as 10, 15 and 5.
Code:
$this->db->group_by(array('uid','ip','user_agent'));
I've also tried including more field names in the the select_sum as arrays but this returns an invalid sql statement.
Any help is appreciated