I want the distinct names from my database table.The table contains column id and name.
I have tried
$diff=Crud::distinct('name')->get();
$diff=Crud::distinct()->get();
Both of them not worked.They are returning the result with duplicates.Here Crud is my eloquent model.
But when i use
$cnt=crud::distinct()->count('name'); //returns the correct count
and
$u=crud::all();
$diff=$u->unique('name'); //returns the distinct names
Why duplicate values are returned while i'm using the distinct? I want distinct names by using distinct.
Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire