MySQL in-operator must match all values?

后端 未结 1 867
独厮守ぢ
独厮守ぢ 2020-12-14 21:06

I\'ve made my own forum. When doing a search I want to find any threads where two (or more) specific users have participated. I came up with this:

SELECT * F         


        
相关标签:
1条回答
  • 2020-12-14 22:04
    SELECT * 
        FROM table1 
            INNER JOIN table2 
                ON table1.threadid=table2.threadid 
        WHERE table2.threadcontributor IN ('1','52512')
        GROUP BY table1.PrimaryKey
        HAVING COUNT(DISTINCT table2.threadcontributor) = 2
    
    0 讨论(0)
提交回复
热议问题