Ravi Jethva Ravi Jethva - 1 year ago 99
PHP Question

How to MaKe Laravel Eloquent "IN" Query?

i want to make query in laravel Eloquent like here its raw mysql query

SELECT * from exampleTbl where id in(1,2,3,4)

i have try this in laravel Eloquent but not working

DB::where("id IN(23,25)")->get()

Answer Source

Here is how you do in Eloquent

$users = User::whereIn('id', array(1, 2, 3))->get();

And if you are using Query builder then :

$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download