Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

4 tables query 1

Status
Not open for further replies.

w11z

Programmer
Mar 26, 2001
40
CA
Hi, I have 4 tables
Table 1: institutions
instID
instName
CityID (FK)

Table 2: cities
cityID
cityName
regionID (FK)
countryID (FK)

Table 3: regions
regionID
regionName
countryID (FK)

Table 4: countries
countryID
countryName

I'm trying to list all the institution name, the city, the region and the country it belongs to. I've tried several ways but never arrive at anything good. Can someone help me?
 
Code:
SELECT institutions.instName
     , cities.cityName
     , regions.regionName
     , countries.countryName
  FROM institutions
INNER
  JOIN cities
    ON cities.cityID = institutions.instID
INNER
  JOIN regions
    ON regions.regionID = cities.regionID
INNER
  JOIN countries
    ON countries.countryID = regions.countryID

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Thank you r937. It worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top