MYSQL: How to JOIN two tables on the same query referencing the same table twice

前端 未结 3 1643
心在旅途
心在旅途 2021-01-26 05:40

I have two tables. I\'m trying to JOIN the sample two tables below with table 1 referencing Table 2 twice. For example if I look at Table 1: Group 2 and Members 7, it should loo

3条回答
  •  误落风尘
    2021-01-26 06:12

    SELECT
      Table_1.*,
      g.Name,
      m.Name
    FROM
      Table_1
      INNER JOIN Table_2 AS g ON Table_1.Group=g.ID
      INNER JOIN Table_2 AS m ON Table_1.Group=m.ID
    WHERE
      Table_1.Group=2
      AND Table_1.Member=7
    

提交回复
热议问题