Raviya Technical
Published in

Raviya Technical

Laravel Eloquent Query | Laravel Wherein Query Example

whereIn(Coulumn_name, Array);

Example 1

SELECT *
FROM users
WHERE id IN (4, 5, 6)
public function index(){$users = User::select("*")
->whereIn('id', [4, 5, 6])
->get();
dd($users);
}
public function index(){$myString = '1,2,3';
$myArray = explode(',', $myString);
$users = User::select("*")
->whereIn('id', $myArray)
->get();
dd($users);}
public function index(){$users = DB::table('users')
->whereIn('name', ['Hardik', 'Vimal', 'Harshad'])
->get();
dd($users);}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store