$userdata=DB::table('user_personal_info')
->leftjoin('chat_user', 'user_personal_info.user_id', '=', 'chat_user.id')
I think this will be more easy:
$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, []);
Try above code instead of yours and kindly make changes as per your requirement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.