如何在laravel 5.4中返回相同列中的所有重复行?

Sou*_*der 2 mysql database duplicates laravel

我想在Jobseekers表中获得所有同名和国家的求职者名单,

**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
Run Code Online (Sandbox Code Playgroud)

我在这里期待的是,

john  |singapore
john  |singapore
Smith |Dubai
Smith |Dubai
Run Code Online (Sandbox Code Playgroud)

这是我在这里尝试的,

 $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); 
Run Code Online (Sandbox Code Playgroud)

任何帮助或建议,将不胜感激.

Pau*_*gel 6

试试这个:

$duplicates = DB::table('jobseekers')
    ->select('fullname','country', DB::raw('COUNT(*) as `count`')
    ->groupBy('fullname', 'country')
    ->having('count', '>', 1)
    ->get();
Run Code Online (Sandbox Code Playgroud)