標籤:image section mysq lan begin sub 表格 country else
| 名稱 |
大陸 |
區 |
人口 |
gdp |
| 阿富汗 |
亞洲 |
652230 |
25500100 |
20343000000 |
| 阿爾巴尼亞 |
歐洲 |
28748 |
2831741 |
12960000000 |
| 阿爾及利亞 |
非洲 |
2381741 |
37100000 |
188681000000 |
| 安道爾 |
歐洲 |
468 |
78115 |
3712000000 |
| 安哥拉 |
非洲 |
1246700 |
20609294 |
100990000000 |
| ... |
名稱:國家名稱
大陸:洲份
面積:面積
人口:人口
gdp:國內生產總值
國家概況
在這教程中,我們會使用SELECT語句,對World表格進行查詢。
Show the name and the continent - but substitute Eurasia for Europe and Asia; substitute America - for each country in North America or South America or Caribbean. Show countries beginning with A or B
顯示名稱和大陸 - 但以歐亞和歐洲替代歐洲和亞洲; 替代美國 - 北美 或南美洲或加勒比地區的每個國家。顯示以A或B開頭的國家
SELECT name,CASE WHEN continent IN(‘Europe‘,‘Asia‘) THEN ‘Eurasia‘ WHEN continent IN(‘North America‘,‘South America‘,‘Caribbean‘) THEN ‘America‘ ELSE continent ENDFROM worldWHERE name LIKE ‘A%‘ OR name LIKE ‘B%‘;
Put the continents right...
- Oceania becomes Australasia
- Countries in Eurasia and Turkey go to Europe/Asia
- Caribbean islands starting with ‘B‘ go to North America, other Caribbean islands go to South America
Show the name, the original continent and the new continent of all countries.
把大陸放在正確的位置...
- 大洋洲成為大洋洲
- 歐亞和土耳其的國家去歐洲/亞洲
- 以‘B‘ 開頭的加勒比群島去北美,其他加勒比群島去南美洲
顯示所有國家的名稱,原始大陸和新大陸。
SELECT name,continent,CASE WHEN continent IN (‘Eurasia‘, ‘Turkey‘) THEN ‘Europe/Asia‘ WHEN continent = ‘Oceania‘ THEN ‘Australasia‘ WHEN continent = ‘Caribbean‘ THEN CASE WHEN name LIKE ‘B%‘ THEN ‘North America‘ ELSE ‘South America‘ END ELSE continent ENDFROM worldORDER BY name ASC;
mysql---SQLZOO:從WORLD選擇教程/ zh