select a.起点 as 起始点,a.终点 as 中转站,b.终点 as 终点 from tb as a join tb as b on a.终点=b.起点 where a.起点='北京' and b.终点='上海'