摘要:本文主要向大家介绍了MySQL数据库之分享几道Mysql常见的面试题 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
本文主要向大家介绍了MySQL数据库之分享几道Mysql常见的面试题 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
<
<p>分享几道Mysql常见的面试题</p>
<p><img style="width: 391px; height: 285px;" alt="\" src="https://www.2cto.com/uploadfile/Collfiles/20180606/20180606085918412.png"></p>
<p>1、每门课都大于80分的学生姓名</p>
<p>select name from table1 GROUP BY name having min(fenshu)>80;(推荐)</p>
<p>select DISTINCT name from table1 where name not in (select DISTINCT name from table1 where fenshu<=80);</p>
<p><img style="width: 630px; height: 158.108px;" alt="\" src="https://www.2cto.com/uploadfile/Collfiles/20180606/20180606085918413.png"></p>
<p>2、删除除了编号不同,其他都相同的冗余学生信息</p>
<p>delete from table2 where bianhao not in (select min(bianhao) from table2 GROUP BY xuehao,name,kechenghao,kecheng,fenshu);</p>
<p>注意:这么写MySQL会报错,You can't specify target table 'table2' for update in FROM clause。这个错误表示不能在同一表中查询的数据作为同一表的更新数据。</p>
<p>应该这么写:delete from table2 where bianhao not in (select a.bianhao from (select * from table2 GROUP BY xuehao,name,kechenghao,kecheng,fenshu)a)</p>
<p>3、一个叫team的表,里面只有一个字段name,一共有4条纪录,分别是a,b,c,d,对应四个球队,现在四个球队进行比赛,用一条sql语句显示所有可能的比赛组合.</p>
<p>select * from team a,team b where a.name>b.name;</p>
本文由职坐标整理并发布,希望对同学们学习MySQL有所帮助,更多内容请关注职坐标数据库MySQL数据库频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号