2
我是新手,laravel和MySQLlaravel子查詢,其中和最大值
MySQL查詢是
select * from table where id in (select max(id) from table group by thread_id)
我的表是
id thread_id
1 45a7
2 123c
3 45a7
4 d056
5 123c
輸出mysql表是
id thread_id
3 45a7
5 123c
4 d056
在這裏,我試圖把我的MySQL查詢laravel如下
MODEL::whereIn('id', function($query){ $query->groupBy('thread_id')})->get();
什麼是我做錯了嗎?下面