我在mysql
有两个表城市id from to
1 101 102
旅行id name
101 ABC
102 XYZ
我正在尝试连接表,这样我将获得ABC作为源和XYZ作为目的地。我尝试了多种组合,但没有得到预期的结果
用不同的别名连接travel
表两次
select c.id,
t1.name as city_from,
t2.name as city_to
from city c
join travel t1 on t1.id = c.`from`
join travel t2 on t2.id = c.`to`