I want to make a query like this
SELECT * FROM batches WHERE id = 20 AND status = 3 OR status = 8
I tried following query but it returning me all records with status = 8
Batch::where('id', 20)->where('status','3')->orwhere('status','8');
What mistake did I make?
Thanks in advance!
你可以使用whereIn
Batch::where('id', 20)->whereIn('status', [3,8]);
You can use Advanced Wheres
Batch::where('id', 20)->where(function($query) use ($staus){
foreach($status as $stat){
$query->orWhere('status','=',$stat);
}
})->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.