Hi
Sorry for late reply.
Original SQL statement after creating it in Access looked like this, with relation set only between City.CityID and Route.CitySID
Code:
SELECT Route.RouteID, Route.OperatorID, Operator.OperatorName, Route.CitySID, City.StopCity, Route.CityEID, Route.NrPolaczenia,
Route.LataPn, Route.OdlotPn, Route.PrzylotPn,
Route.LataWt, Route.OdlotWt, Route.PrzylotWt,
Route.LataSr, Route.OdlotSr, Route.PrzylotSr,
Route.LataCz, Route.OdlotCz, Route.PrzylotCz,
Route.LataPt, Route.OdlotPt, Route.PrzylotPt,
Route.LataSo, Route.OdlotSo, Route.PrzylotSo,
Route.LataNd, Route.OdlotNd, Route.PrzylotNd,
Route.LastUpdate
FROM Ticket, City INNER JOIN (Operator INNER JOIN Route ON Operator.OperatorID = Route.OperatorID) ON (City.StopID = Route.CitySID) AND (City.StopID = Route.CitySID);
I have tried it also a with relationship set (City.CityID and Route.CitySID) and second one to (City.CityID and Route.CityEID),
what created a duplicate City table in Relationship view, but query was displaying an error and didn't show View view at all.
Then I have changed SQL statement manually to this one below.
Code:
SELECT Route.RouteID, Route.OperatorID, Operator.OperatorName,
Route.CitySID,
(SELECT StopCity FROM City WHERE City.StopID = Route.CitySID) AS CityFrom, (SELECT StopCountryCode FROM City WHERE City.StopID = Route.CitySID) AS CountryFrom,
Route.CityEID,
(SELECT StopCity FROM City WHERE City.StopID = Route.CityEID) AS CityTo, (SELECT StopCountryCode FROM City WHERE City.StopID = Route.CityEID) AS CountryTo,
Route.NrPolaczenia, Route.LataPn, Route.OdlotPn, Route.PrzylotPn, Route.LataWt, Route.OdlotWt, Route.PrzylotWt, Route.LataSr, Route.OdlotSr, Route.PrzylotSr,
Route.LataCz, Route.OdlotCz, Route.PrzylotCz, Route.LataPt, Route.OdlotPt, Route.PrzylotPt, Route.LataSo, Route.OdlotSo, Route.PrzylotSo, Route.LataNd, Route.OdlotNd, Route.PrzylotNd,
Route.LastUpdate
FROM Operator INNER JOIN Route ON Operator.OperatorID = Route.OperatorID;
It worked and both cities names and both country codes were displayed correctly, but I don't think this is a way how it suppose to be done and I doubt it is efficient code in a long run.
I can't believe that there isn't better way to join two fields form one table to other to pull names for both city codes from City table to Route table.