- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Mysql面试题2
Mysql面试题2
涓嶉敊鐨剆ql闈㈣瘯棰樎?聽
Student(s_no,sname,age,sex) 瀛︾敓琛?
Course(c_no,cname,t_no) 璇剧▼琛?
SC(s_no,c_no,score) 鎴愮哗琛?
Teacher(t_no,Tname) 鏁欏笀琛?
闂锛?
1銆佹煡璇⑩€?01鈥濊绋嬫瘮鈥?02鈥濊绋嬫垚缁╅珮鐨勬墍鏈夊鐢熺殑瀛﹀彿锛?
聽聽select a.s_no from (select s_no,score from SC where c_no=001) a,(select s_no,score
聽聽from SC where c_no=002) b
聽聽where a.scoreb.score and a.s_no=b.s_no;
2銆佹煡璇㈠钩鍧囨垚缁╁ぇ浜?0鍒嗙殑鍚屽鐨勫鍙峰拰骞冲潎鎴愮哗锛?
聽 聽 select s_no,avg(score)
聽 聽 from sc
聽 聽 group by s_no having avg(score) 60;
3銆佹煡璇㈡墍鏈夊悓瀛︾殑瀛﹀彿銆佸鍚嶃€侀€夎鏁般€佹€绘垚缁╋紱
聽聽select Student.s_no,Student.sname,count(SC.c_no),sum(score)
聽聽from Student left Outer join SC on Student.s_no=SC.s_no
聽聽group by Student.s_no,sname
4銆佹煡璇㈠鈥滄潕鈥濈殑鑰佸笀鐨勪釜鏁帮紱
聽聽select count(distinct(Tname))
聽聽from Teacher
聽聽where Tname like 鏉?;
5銆佹煡璇㈡病瀛﹁繃鈥滃彾骞斥€濊€佸笀璇剧殑鍚屽鐨勫鍙枫€佸鍚嶏紱
聽 聽 select Student.s_no,Student.sname
聽 聽 from Student聽聽
聽 聽 where s_no not in (select distinct( SC.s_no) from SC,Course,Teacher
where聽聽SC.c_no=Course.c_no and Teacher.t_no=Course.t_no and Teacher.Tname=鍙跺钩);
6銆佹煡璇㈠杩団€?01鈥濆苟涓斾篃瀛﹁繃缂栧彿鈥?02鈥濊绋嬬殑鍚屽鐨勫鍙枫€佸鍚嶏紱
聽聽select Student.s_no,Student.sname from Student,SC where Student.s_no=SC.s_no and
SC.c_no=001and exists( Select * from SC as SC_2 where SC_2.s_no=SC.s_no and
SC_2.c_no=002);
7銆佹煡璇㈠杩団€滃彾骞斥€濊€佸笀鎵€鏁欑殑鎵€鏈夎鐨勫悓瀛︾殑瀛﹀彿銆佸鍚嶏紱
聽聽select s_no,sname
聽聽from Student
聽聽where s_no in (select s_no from SC ,Course ,Teacher where SC.c_no=Course.c_no and
Teacher.t_no=Course.t_no and Teacher.Tname=鍙跺钩 group by s_no having
count(SC.c_no)=(select count(c_no) from Course,Teacher聽聽where
Teacher.t_no=Course.t_no and Tname=鍙跺钩));
8銆佹煡璇㈣绋嬬紪鍙封€?02鈥濈殑鎴愮哗姣旇绋嬬紪鍙封€?01鈥濊绋嬩綆鐨勬墍鏈夊悓瀛︾殑瀛﹀彿銆佸鍚嶏紱
聽聽Select s_no,sname from (select Student.s_no,Student.sname,score ,(select score
from SC SC_2 where SC_2.s_no=Student.s_no and SC_2.c_no=002) score2
聽聽from Student,SC where Student.s_no=SC.s_no and c_no=001) S_2 where score2 60);
10銆佹煡璇㈡病鏈夊鍏ㄦ墍鏈夎鐨勫悓瀛︾殑瀛﹀彿銆佸鍚嶏紱
聽 聽 select Student.s_no,Student.sname
聽 聽 from Student,SC
聽 聽 where Student.s_no=SC.s_no group by聽聽Studen
您可能关注的文档
最近下载
- “金税四期”背景下的税务风险管理——基于LZ集团公司的案例分析.pdf VIP
- 欧洲规范-NF P94-220-2-外文.pdf VIP
- 2026上海电力股份有限公司校园招聘笔试备考题库及答案解析.docx VIP
- 净制中药饮片引用原药材检验结果验证方案.docx VIP
- 2柴油安全技术说明书.doc VIP
- 个人劳务用工合同.docx VIP
- T /CIPS 015—2025 专利池构建规范.pdf
- 在线网课学习课堂《心理·生活-人生(华北电大 )》单元测试考核答案.docx VIP
- 2025年螺栓等紧固件行业深度研究报告.docx
- 体例格式10:工学一体化课程《windows服务器基础配置与局域网组建》任务4学习任务信息页.docx VIP
文档评论(0)