How To Get Data From SQL In Laravel Using WhereIn And Take Function?
How can I get data of each value in the array. I want only 1 result from both values.
$userBikes = array('862549040389788','12345'); $data = DB::table('geolocation') ->whereIn('Imei',$userBikes) ->take(1) ->get();
["28.537857", "77.269325", "862549040389788"]
but I am expecting this result:
["28.537857", "77.269325", "862549040389788"] ["28.537857", "77.269325", "12345"]
Based on your comments, I think you want a group by query.
$userBikes = array('862549040389788','12345'); $data = DB::table('geolocation') ->whereIn('Imei', $userBikes) ->groupBy('Imei') ->selectRaw('any_value(id) as id, any_value(Lat) as Lat, any_value(Lng) as Lng, any_value(created_at) as created_at, Imei') ->get();
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?