1 回答
TA贡献1784条经验 获得超9个赞
在下面的查询
$subject_ids = DB::table('question_sets')
->select('subject_id')
->where('test_section_id','=',$testDetail->test_section_id)
->distinct()->get();
您正在获取一个集合,如果您想要一个特定的值,则可以使用它first() ,然后您可以
$subject_id = DB::table('question_sets')
->select('subject_id')
->where('test_section_id','=',$testDetail->test_section_id)
->distinct()
->pluck('name')
->first();
和
$topic_ids = DB::table('topics')
->select('id')
->where('subject_id','=',$subject_id)
->get();
或者,如果您想与所有$ subject_ids匹配,则应使用toArray()和whereIn喜欢
$subject_ids = DB::table('question_sets')
->select('subject_id')
->where('test_section_id','=',$testDetail->test_section_id)
->distinct()
->pluck('subject_id')
->toArray();
和
$topic_ids = DB::table('topics')
->select('id')
->whereIn('subject_id', $subject_ids)
->get();
- 1 回答
- 0 关注
- 167 浏览
添加回答
举报