我是SQL新手。目前,我正在學習編寫複雜的查詢。關於SQL查詢
我有三張桌子。 國家 - 有國家的名單
-----------+-------------
CountryId | CountryName
-----------+-------------
1 | India
2 | Srilanka
3 | Pakistan
4 | Bangladesh
5 | Nepal
6 | America
7 | Japan
8 | China
9 | Russia
10 | Canada
11 | Australia
---------------------------------------
城市 - 鄉村的城市名單
--------+-------------+-----------
CityId | CityName | CountryId
--------+-------------+-----------
1 | Chennai | 1
2 | Washington | 6
3 | Moscow | 9
4 | Tokyo | 7
5 | Beijing | 8
6 | Sydney | 11
7 | Bangalore | 1
8 | Nagercoil | 1
9 | AmericaCity | 6
10 | Kathmandu | 5
11 | Dhaka | 4
12 | Lahore | 3
--------------------------------------
機場 - 機場在城市
AirportId | AirportName | CityId
-----------+-------------+--------
1 | Airport1 | 1
2 | Airport2 | 4
3 | Airport3 | 5
4 | Airport4 | 1
5 | Airport5 | 6
6 | Airport6 | 3
7 | Airport7 | 5
8 | Airport8 | 7
9 | Airport9 | 6
10 | Airport10 | 3
11 | Airport11 | 11
12 | Airport12 | 10
13 | Airport13 | 12
---------------------------------
問題清單:我想找回所有有機場數量的國家,如
Output:
countryName Airports
India 3
Srilanka 0
......... etc.
這不是功課,是嗎? – dasblinkenlight 2012-01-17 12:01:05