在 mySql 中,我可以对最新日期的数据执行如下操作:
select * from tbl where date = 'select max(date) from tbl';
但我不知道该怎么做这是laravel?怎么做?
最佳答案
使用 orderbBy()
:
TblModel::orderBy('date','DESC')->first();
或者
DB::table('tbl')->orderBy('date', 'DESC')->first();
更新:
TblModel::where('date', TblModel::max('date'))->orderBy('date','desc')->get();
关于laravel - 如何从laravel中的最新日期检索数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48780095/