【发布时间】:2017-11-20 06:48:05
【问题描述】:
我想打印前三个热门标签(使用最多的标签)的名称。 为了获得趋势 tags id,我使用了这个正在工作的查询
DB::table('review_tag')->select('tag_id')->groupBy('tag_id')->orderBy(DB::raw('count(tag_id)'), 'desc')->take(3)->get();
现在我需要使用 id 从表 tags 中获取标签的名称,我使用上述查询从 review_tag 表中获得
我试过用这个但是没用
B::table('review_tag')->join('tags', 'tags.id', '=', 'review_tag.tag_id')->select('tags.name')->groupBy('tag_id')->orderBy(DB::raw('count(tag_id)'), 'desc')->take(3)->get();
【问题讨论】:
标签: php mysql laravel laravel-eloquent laravel-query-builder