MYSQL AND OR On Many To Many Table

后端 未结 2 745
暗喜
暗喜 2021-01-26 21:11

Kind of a convoluted question but, basically I have a many to many table word_relationships:

+-----+--------+--------+
|  ID | WORD_A | WORD_B |
+--         


        
2条回答
  •  旧巷少年郎
    2021-01-26 21:57

    This should work:

    SELECT 
      id 
    FROM 
      word_relationships
    WHERE 
     (Word_A = w1 AND Word_B = w2)
    OR 
     (Word_A = w2 AND Word_B = w1)
    

提交回复
热议问题