Laravel: Cách lấy mỗi Subject một Article đầu tiên với quan hệ Topic
$rs=DB::table('subjects as a')->join('topics as b','a.id','b.subjectId')->join('articles as c','b.id','c.topicId')->select('a.id','subjectName','categoryId',DB::raw('min(c.id) as articleId'))->where('a.status','1')->where('b.status','1')->where('c.status','1')->groupBy('a.id','subjectName','categoryId')->orderBy('subjectRank')->get();