我很困惑,想知道如何根据两个不同的外键显示一个包含两列(城市名称)的表格。在这种情况下,我想显示制造商城市和仓库城市,而他们都需要访问CityID。
这是我到目前为止所得到的:
SELECT s.StkName, c.CityName AS "Manufacturer City", c.CityName AS
"Warehouse City", s.SellingPrice FROM
STOCKITEM7364 s
LEFT OUTER JOIN MANUFACTURER7364 m ON m.ManID = s.ManID
LEFT OUTER JOIN CITY7364 c ON c.CityID = m.CityID
LEFT OUTER JOIN WAREHOUSE7364 w ON w.WHID = s.WHID AND w.CityID = c.CityID
WHERE s.StkName LIKE '%n' OR s.StkName LIKE '%e' OR s.StkName LIKE '%o' OR
s.StkName LIKE '%p' OR s.StkName LIKE '%s';
我非常感谢有关sql的任何帮助或解释