我想写;
匹配1:jonathan vs jenny,
匹配2:sam vs ruby,
匹配3:arif vs pamee
我尝试了很多查询但未能完成。
SELECT table1.boy_id, table1.girl_id, table1.ID, table2.id, table2.name, table2.score
FROM table1
INNER JOIN table2
答案 0 :(得分:2)
SELECT a.ID,
b.name BoyName,
c.name GirlName
FROM table1 a
INNER JOIN table2 b
On a.boy_id = b.id
INNER JOIN table2 c
ON a.girl_id = c.id
您需要在table2
上加入table1
两次,因为table1
中有两列引用了table2
。