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 look up the ID in Table 2 and give me an output of:
Group Members Name Name
2 7 Blue Dog
Table 1
Group Members
2 7
3 8
5 10
Table 2
ID Name
1 Green
2 Blue
3 Yellow
4 Orange
5 Red
6 Elephant
7 Dog
8 Cat
9 Chicken
10 Mouse
Any Advice? Thanks
解决方案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