更新时间:2023-02-26 09:54:32
您必须两次加入tblLocation表。这看起来像
You must JOIN the tblLocation table two times. That looks something like
SELECT tblRoute.Id as RouteId, a.Cityname as SourcePlace, b.Cityname as DestinationPlace
FROM tblRoute
INNER JOIN tblCity a ON tblRoute.SourcePlace=a.Id
INNER JOIN tblCity b ON tblRoute.DestinationPlace=b.Id
SELECT a.Id as RouteId, b.Cityname as SourcePlace, c.Cityname as DestinationPlace
from tblRoute a inner join tblLocation b on a.SourcePlace = b.Id
left outer join tblLocation c on a.DestinationPlace = c.Id
在SQL Server上测试 - 2008 R2 ,它工作正常。
Tested it on SQL Server - 2008 R2, It works fine.