MySQL练习(06)

题目来源:https://sqlzoo.net/

  在学了将近一个月的Java编程后,老师推荐了一个网址:https://sqlzoo.net/,说让我们自己练习MySQL。
  在网站里“溜达”了一圈后,感觉这个网站确实不错!首先,里面有许多题目可供练习,从最基础的增删改查到多表操作…如果能练习完里面的所有题目,那么MySQL技能将会有一个很大的提升!其次,里面的数据是真实的,全部来源于现实。最后,网站中的数据来源非常广泛,社会、人文等应有尽有,在这个网站中学习MySQL,不仅能学习到专业知识,也能了解其他方面的知识,增加见识。
  所以,开了这个专栏,用于记录。


SELECT from Nobel Tutorial

在这里插入图片描述


1.更改查詢以顯示1950年諾貝爾獎的獎項資料。

select * from nobel where yr=1950;

在这里插入图片描述


2. 顯示誰贏得了1962年文學獎(Literature)。
select winner from nobel where yr=1962 and subject='Literature';

在这里插入图片描述


3.顯示“愛因斯坦”('Albert Einstein') 的獲獎年份和獎項。
select yr,subject from nobel where winner='Albert Einstein';

在这里插入图片描述


4.顯示2000年及以後的和平獎(‘Peace’)得獎者。
select winner from nobel where yr>=2000 and subject='Peace';

在这里插入图片描述


5.顯示1980年至1989年(包含首尾)的文學獎(Literature)獲獎者所有細節(年,主題,獲獎者)。
select * from nobel where (yr between 1980 and 1989) and subject='Literature';

在这里插入图片描述


6. 顯示總統獲勝者的所有細節: 西奧多•羅斯福 Theodore Roosevelt 伍德羅•威爾遜 Woodrow Wilson 吉米•卡特 Jimmy Carter
select * from nobel where winner in('Theodore Roosevelt','Woodrow Wilson','Jimmy Carter');

在这里插入图片描述


7.顯示名字為John 的得獎者。 (注意:外國人名字(First name)在前,姓氏(Last name)在後)
select winner from nobel where winner like('John %');

在这里插入图片描述


8. 顯示1980年物理學(physics)獲獎者,及1984年化學獎(chemistry)獲得者。
select *from nobel where (yr=1980 and subject='physics') or (yr=1984 and subject='chemistry');

在这里插入图片描述


9. 查看1980年獲獎者,但不包括化學獎(Chemistry)和醫學獎(Medicine)。
select * from nobel where (subject not in('Chemistry','Medicine')) and yr=1980;

在这里插入图片描述


10. 顯示早期的醫學獎(Medicine)得獎者(1910之前,不包括1910),及近年文學獎(Literature)得獎者(2004年以後,包括2004年)。
select * from nobel where (yr<1910 and subject='Medicine') or (yr>=2004 and subject='Literature');

在这里插入图片描述


11. Find all details of the prize won by PETER GRÜNBERG Non-ASCII characters
select * from nobel where winner='PETER GRÜNBERG ';

在这里插入图片描述


12. 查找尤金•奧尼爾EUGENE O'NEILL得獎的所有細節 Find all details of the prize won by EUGENE O'NEILL
select * from nobel where winner='EUGENE O''NEILL';

在这里插入图片描述


13.騎士列隊 Knights in order 列出爵士的獲獎者、年份、獎頁(爵士的名字以Sir開始)。先顯示最新獲獎者,然後同年再按名稱順序排列。
select winner,yr,subject from nobel where winner like('Sir%') order by yr desc,winner asc;

在这里插入图片描述


14.The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1. Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.
select winner,subject from nobel where yr=1984 order by subject in('Chemistry','Physics'),subject asc,winner asc;

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值