我有一张表门票(用户名,帖子,方案)用户可能有可能的帖子。例如,
____________________________________
username | posts | scheme |
__________|____________|___________|
A | post1 | 10 |
__________|____________|___________|
B | post2 | 2 |
__________|____________|___________|
B | post 3 | 13 |
__________|____________|___________|
A | post 4 | 21 |
__________|____________|___________|
A | post 5 | -1 |
__________|____________|___________|
我的查询应该生成具有标题总数和总声誉的输出不同用户名。IE,
_______________________
|A | 3 | 30 |
|____|_______|_________|
|B | 2 | 15 |
|____|_______|_________|
我的模型功能:-
function getAllUsers(){
$this->db->distinct();
$this->db->select('username,COUNT(title) AS numtitle');
$this->db->where('site_referers_id',1);
return $this->db->get('tbl_tickets');
}
但这似乎不起作用:(