- join时使用find_in_set()
$fields = ['tagId', DB::raw('GROUP_CONCAT(cp.name) as className')];
Tag::select($fields)
->leftJoin('mg_class_public as cp',function ($join) {
$join->whereRaw(DB::raw('FIND_IN_SET(cp.id, mg_tag.class_ids)'));
})
->get()
->toArray();
- select 是使用find_in_set()
User::where('userId', $this->userId)
->whereRaw(DB::raw("FIND_IN_SET({$routerId}, router)"))
->value('router');