$userdata=DB::table('user_personal_info')
->leftjoin('chat_user', 'user_personal_info.user_id', '=', 'chat_user.id')
答案 0 :(得分:0)
我认为这会更容易:
$sql = 'SELECT GROUP_CONCAT(chat_user) as user,
user_id,user_personal_info.user_id FROM TableName
where user_personal_info.user_id = chat_user.id GROUP BY
user_personal_info.user_id';
$users = DB::select($sql, []);
尝试使用上面的代码代替您的代码,并根据需要进行更改。