有人可以在laravel
SELECT chat_id
FROM chat_user
GROUP BY chat_id
HAVING MIN(user_id) = <user_id_1> AND MAX(user_id) = <user_id_2>;
答案 0 :(得分:1)
查询生成器或雄辩的方式。 DB :: table或ChatUser ::
$data = DB::table('chat_user')
->select('chat_id')
->groupBy('chat_id')
->havingRaw('MIN(user_id) = '.$user_id1.' AND MAX(user_id) = '.$user_id2.'')
->get();
答案 1 :(得分:0)
Lim Kean Phang已回答了 谢谢林基鹏!