我正在寻找一个查询来从我的函数的两个participant_id参数中获取会话ID:
获取conversation_id的Php函数
public function findByUsers($user1,$user2)
Mysql表participant_conversation
+--------------+-------------------------+
|participant_id| participant_conversation|
+--------------+-------------------------+
|42360 |1 |
+--------------+-------------------------+
|42362 |5 |
+--------------+-------------------------+
|42363 |1 |
+--------------+-------------------------+
感谢您的帮助
编辑:我找到了解决方案
SELECT DISTINCT ( participant_conversation )
FROM users_conversations_participants
WHERE participant_id IN ( 42360, 42361 )
GROUP BY participant_id
LIMIT 0 , 30
答案 0 :(得分:0)
以下问题:
$sql = "SELECT participant_id, participant_conversation FROM participant_conversation WHERE participant_id IN ($user1, $user2)";
然后可以简单地使用while循环来获取各自的participant_converation。