2表table1和表2;要求是从表2中映射table1中的两列
SELECT , t2.people_names, t2.peoples_names
FROM ( table1 t1 JOIN table2 t2 ON t2.people_ids=t1.people1 )
如果我添加FROM语句和AND,为了映射列people2,我收到错误。
FROM (table1 t1 JOIN table2 t2 ON t2.people_ids=t1.people1 AND
t2.people_ids=t1.people2 )
答案 0 :(得分:1)
您必须两次加入people_names
表。
SELECT t1.people1, tnames1.peoples_names, t1.people2, tnames2.peoples_names
FROM table1 t1 JOIN table2 tnames1 ON tnames1.people_ids = t1.people1
JOIN table2 tnames2 ON tnames2.people_ids = t1.people2