I have this join:
Return DB::table('volunteer')
->join('volunteer_volunteer_category', 'volunteer_volunteer_category.volunteer_id', '=', 'volunteer.id')
->select(array('*','volunteer.id AS link_id'))
->where('is_published', '=', 1)
But it unsurprisingly returns duplicate records, so I try to use distinct()
:
Return DB::table('volunteer')
->join('volunteer_volunteer_category', 'volunteer_volunteer_category.volunteer_id', '=', 'volunteer.id')
->select(array('*','volunteer.id AS link_id'))
->distinct()
->where('is_published', '=', 1)
but I want to use distinct()
on a specific single field which I'd easily be able to do in SQL. It seems distinct()
does not take parameters, i.e. I can't say distinct('volunteer.id')
.
Can anyone point me to how can I remove my duplicate records? I bet this is another forehead slapper for me.
->group_by('volunteer.id')
as well as->distinct()
. – Phellem->group_by('volunteer.id')
makes my pagination links disappear!!??? – Phellem