我想在求职者表格中获取所有同名和国家的求职者列表。
**id** |fullname |country |phone_number
1 |John | singapore |0988884434
2 |john | singapore |0933333333
3 |Michael |Malaysia |0888888888
4 |Smith |Dubai |082388888888
5 |Smith |Dubai |03939494944
what am I expect here is,
john |singapore
john |singapore
Smith |Dubai
Smith |Dubai
我在这里尝试的是:
$duplicates = DB::table('jobseekers')
->select(array('jobseekers.fullname','jobseekers.country', DB::raw('COUNT('*')'))
->groupBy('jobseekers.fullname','jobseekers.country')
->having(DB::raw('COUNT('*')'))
->get();
var_dump($duplicates);
非常感谢您提供的任何帮助或建议。
fullname
,country
, 0 fromjobseekers
group byfullname
,country
havingcount
> 1) - undefinedcountry
是一个"未知列",但我刚刚修复了你代码中的另一个错误(COUNT('*')
应该是COUNT(*)
)。 - undefined