如何做到这一点???
表1
|person_id|name|division|
表2
|job_id|declare|person1_id|person2_id|
输出:
|job_id|declare|person1_name|person2_name|
答案 0 :(得分:1)
select t2.job_id,
t2.declare,
tp1.name as person1_name,
tp2.name as person2_name
from table2 t2
left join table1 tp1 on tp1.person_id = t2.person1_id
left join table1 tp2 on tp2.person_id = t2.person2_id