原生sql
select * from homework where (id between 1 and 10 or id between 50 and 70) and complete = 1 and (title like 'a%' or title like 'b%');
ORM查詢
$homeworks = Homework::where(function ($query) { $query->whereBetween('id', [1, 10]) ->orWhereBetween('id', [50, 70]); })->where('complete', 1) ->where(function ($query) { $query->where('title', 'like', 'a%') ->orWhere('title', 'like', 'b%'); })->get();
来源:CSDN
原文:https://blog.csdn.net/xcqingfeng/article/details/80364618