时间:2021-07-01 10:21:17 帮助过:39人阅读
在这教程中,我们会使用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开头的国家
- <span style="color: #0000ff;">SELECT</span><span style="color: #000000;"> name,
- </span><span style="color: #ff00ff;">CASE</span> <span style="color: #0000ff;">WHEN</span> continent <span style="color: #808080;">IN</span>(<span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Europe</span><span style="color: #ff0000;">‘</span>,<span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Asia</span><span style="color: #ff0000;">‘</span><span style="color: #000000;">)
- </span><span style="color: #0000ff;">THEN</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Eurasia</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">WHEN</span> continent <span style="color: #808080;">IN</span>(<span style="color: #ff0000;">‘</span><span style="color: #ff0000;">North America</span><span style="color: #ff0000;">‘</span>,<span style="color: #ff0000;">‘</span><span style="color: #ff0000;">South America</span><span style="color: #ff0000;">‘</span>,<span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Caribbean</span><span style="color: #ff0000;">‘</span><span style="color: #000000;">)
- </span><span style="color: #0000ff;">THEN</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">America</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">ELSE</span> continent <span style="color: #0000ff;">END</span>
- <span style="color: #0000ff;">FROM</span><span style="color: #000000;"> world
- </span><span style="color: #0000ff;">WHERE</span> name <span style="color: #808080;">LIKE</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">A%</span><span style="color: #ff0000;">‘</span> <span style="color: #808080;">OR</span> name <span style="color: #808080;">LIKE</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">B%</span><span style="color: #ff0000;">‘</span>;
Put the continents right...
把大陆放在正确的位置...
- <span style="color: #0000ff;">SELECT</span><span style="color: #000000;"> name,continent,
- </span><span style="color: #ff00ff;">CASE</span> <span style="color: #0000ff;">WHEN</span> continent <span style="color: #808080;">IN</span> (<span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Eurasia</span><span style="color: #ff0000;">‘</span>, <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Turkey</span><span style="color: #ff0000;">‘</span><span style="color: #000000;">)
- </span><span style="color: #0000ff;">THEN</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Europe/Asia</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">WHEN</span> continent <span style="color: #808080;">=</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Oceania</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">THEN</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Australasia</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">WHEN</span> continent <span style="color: #808080;">=</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">Caribbean</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">THEN</span>
- <span style="color: #ff00ff;">CASE</span>
- <span style="color: #0000ff;">WHEN</span> name <span style="color: #808080;">LIKE</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">B%</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">THEN</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">North America</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">ELSE</span> <span style="color: #ff0000;">‘</span><span style="color: #ff0000;">South America</span><span style="color: #ff0000;">‘</span>
- <span style="color: #0000ff;">END</span>
- <span style="color: #0000ff;">ELSE</span><span style="color: #000000;"> continent
- </span><span style="color: #0000ff;">END</span>
- <span style="color: #0000ff;">FROM</span><span style="color: #000000;"> world
- </span><span style="color: #0000ff;">ORDER</span> <span style="color: #0000ff;">BY</span> name <span style="color: #0000ff;">ASC</span>;
mysql---SQLZOO:从WORLD选择教程/ zh
标签:image section mysq lan begin sub 表格 country else