答案 0 :(得分:1)
要获得这两个用户所在的所有线程,您可以
select thread_id
from your_table
where user_id in (1,2)
group by thread_id
having count(distinct user_id) = 2
获取具有多个用户的所有线程
select thread_id
from your_table
group by thread_id
having count(distinct user_id) >= 2
答案 1 :(得分:0)
我不太清楚你想要什么,但据我所知,我认为这是。
select thread_id, COUNT(thread_id) AS dup_count from participant_thread as participant
GROUP BY thread_id
HAVING (COUNT(thread_id) > 1)
答案 2 :(得分:-1)
select thread_id, user_id
from thread.thread_table
where thread_id in (
select thread_id
from thread.thread_table
group by thread_id
having count(user_id) > 1
);