我希望基于public function GetFriend($other,$user)
{
$list = $this->makeModel()
->where(function ($query) use ($other, $user) {
$query->where('otheruser',$other)
->orWhere('user_id',$user);
})
->get();
return $list;
}
group
results
。{/ p>
演示:http://sqlfiddle.com/#!9/ab315b/1
例如,如果timestamp
date
有3个结果,那么我想要输出,如下所示
14
根据图像和查询:
在这里,我已将我执行: http://sqlfiddle.com/#!9/ab315b/1
请帮帮我 在此先感谢!!!!
答案 0 :(得分:1)
您可以使用Group_concat
在此处连接多行。像
SELECT created_at, Group_concat(project_desc, ' ') FROM work_desc
Group By CAST(created_at AS DATE)
ORDER BY created_at DESC;
其输出看起来像
created_at Group_concat(project_desc, ' ')
2017-11-14T10:18:54Z this my first day report employeee 2222 ,this my first day report employeee 33333 ,this my first day report employeee 44444
2017-11-12T18:30:00Z this my yesterday day report employeee 2222 ,this my yesterday day report employeee 33333
你可以稍微计算一下,以产生我想要的输出。
修改强>
我相信这会返回您要查找的输出
SELECT concat(Group_concat(concat('<tr><td>', project_name,
'</td><td>', project_desc, '</td>')
SEPARATOR '</tr>'), '</tr>')
FROM work_desc GROUP BY CAST(created_at AS DATE)
ORDER BY created_at DESC
希望这有帮助。