How to return all duplicates rows in same columns in laravel 5.4?

Viewed 3935

I want to get all the list of jobseekers which is the same fullname and country, in Jobseekers Table,

**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

this is what i tried here,

 $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); 

Any help or advice you have would be greatly appreciated.

2 Answers
Related