我需要使用where,between和类似的运算符将以下MySQL代码更改为laravle格式:
select count(id) from tbl1
where created_at BETWEEN
'2018-12-10%' AND '2018-12-12%'
答案 0 :(得分:1)
我找到了如下答案:
\DB::table('tbl1')->whereBetween('created_at',[$sdate.'%', $enddate.'%'])->count();
答案 1 :(得分:0)
如果您使用模型,则可以使用whereBetween
方法,请看以下示例:
User::query()->whereBetween('created_at', [$start, $end])->count();