Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Joining 3 tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-08-24 : 08:28:02
Vivin writes "I have 3 tables that are:

CITY with attributes
cityid(pk)
citynmae
airportname
citypop

CLIMATE which has attributes
month (pk)
cityid (pk,fk)
temperature
humidity
precipitation

DISTANCE
distance
traveltime
* For this DISTANCE table, I need to get 2 Primary keys and 2 foreign keys from CITY table.

My tables should be like this:
*CITY*

CITYID---CITYNAME----AIRPORTNAME------CITYPOP
1000-----Amsterdam-----Amsterdam-----------5000000
2000-----Sydney----------KingsFord Smith----4000000
3000-----Tokyo----------Tokyo Airport--------7000000



*DISTANCE*

CITYID(1) CITYID(2)---DISTANCE--------TRAVELTIME
1000-----2000-----------3000 km-------------25 hours
(means from Amsterdam-Tokyo is 3000kms and travel time 25 hours)
1000-----3000----------2000 km--------------20 hours
2000-----3000----------1500 km--------------15 hours


How do I do this kind of question:
Which city is the farthest from Amsterdam and how long does it take to travel there?"

   

- Advertisement -