jeudi 30 mars 2017

Using distinct or group by?

This is how my table looks like:

enter image description here

Now i have this query for suggestion:

  $data = Districts::distinct()->whereRaw('LOWER(district) like ?', [strtolower('%'.$district . '%')])->orWhereRaw('LOWER(region) like ?', [strtolower('%'.$district . '%')])->select('region', 'district')->get();

What i want is that if user enter for example: Kreis 2 to get only one record Kreis 2, in my case it get few of them because Kreis 2 have 3 regions. Any suggestion how can do that?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire