id sm_id to_id
1 3 2
2 4 1
3 3 3
4 3 2
5 3 3
6 4 1
如何计算 sm_id
有多少次出现?使用laravel比较和计数两个表格
我有两个输入,第一个sm_id
和第二个to_id
,我想根据输入计数值的发生。
为sm_id = 4 and to_id = 1
预期的结果将是2
这里是我试过
$us = \DB::table('mgs')
->where('sm_id', '=', DB::raw('to_id'))
->where('to_id', '=', DB::raw('sm_id'))
->groupBy('sm_id')
->count();
print_r($us);die;
这样一个愚蠢的问题,谢谢@alexey –
很高兴它有帮助。 –