select table1.id, table2.name from table1 join table2 on table2.id = table1.id join table3 on table3.name = table2.name