hrishi hrishi - 3 months ago 25
MySQL Question

Join two tables on different columns

I have two tables like below in mysql


id from to

1 101 102


id name

101 ABC

102 XYZ

I am trying to join table such that I will get ABC as source and XYZ as destination. I tried multiple combinations but not getting expected result


Join the travel table twice with different alias names

select, as city_from, as city_to
from city c
join travel t1 on = c.`from`
join travel t2 on = c.`to`