【发布时间】:2011-10-18 05:55:21
【问题描述】:
SELECT people.first_name AS "First Name", people.last_name AS "Last Name", countries.name AS "Country1", territories.name AS "Territory1", cities.name AS "City1", countries.name AS "Country2", territories.name AS "Territory2", cities.name AS "City2"
FROM adb_people AS people
JOIN root_cities AS cities ON people.city1 = cities.id
AND people.city2 = cities.id
JOIN root_territories AS territories ON people.prov_state1 = territories.id
AND people.prov_state2 = territories.id
JOIN root_countries AS countries ON people.country1 = countries.id
我在这里要做的是将 Country1 (id) 链接到 Country1 (name) 并仅显示名称。 此代码示例仅在 Country1,Territory1,City1 与 Country2,Territory2,City2 相同时才有效
我想我的问题是我如何进行 JOIN。我是 SQL 方面的新手。我已经阅读了互联网上的 JOINS(谷歌搜索并阅读了前几个教程),但是在这种情况下,我所阅读的任何内容都没有任何帮助。
对于我在这里做错的事情,我真的很感激。也许是朝着正确的方向轻推?
【问题讨论】: