版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、實(shí)驗(yàn)三:數(shù)據(jù)庫(kù)的嵌套查詢實(shí)驗(yàn)實(shí)驗(yàn)?zāi)康模杭由顚?duì)嵌套查詢語(yǔ)句的理解。實(shí)驗(yàn)內(nèi)容:使用in、比較符、any或all和exists操作符進(jìn)行嵌套查詢操作。實(shí)驗(yàn)步驟:一. 使用帶in謂詞的子查詢1. 查詢與劉晨在同一個(gè)系學(xué)習(xí)的學(xué)生的信息:比較select * from student where sdept in (select sdept from student where sname=劉晨)與: select * from student where sdept = (select sdept from student where sname=劉晨) 的異同比較: select * from stu
2、dent where sdept = (select sdept from student where sname=劉晨) and sname 劉晨與: select s1.* from student s1, student s2 where s1.sdept=s2.sdept and s2.sname=劉晨的異同2. 查詢選修了課程名為信息系統(tǒng) 的學(xué)生的學(xué)號(hào)和姓名:比較select sno, sname from student where sno in(select sno from sc where cno in (select cno from course where cname=
3、信息系統(tǒng))與: select sno, sname from student where sno in(select sno from sc, course where o=o and cname=信息系統(tǒng)) 3. 查詢選修了課程1和課程2的學(xué)生的學(xué)號(hào):select sno from student where sno in (select sno from sc where cno=1)and sno in (select sno from sc where cno=2)比較: 查詢選修了課程1或課程2的學(xué)生的sno:select sno from sc where cno=1 or cno
4、=2比較連接查詢: select a.sno from sc a, sc b where a.sno=b.sno and a.cno=1 and b.cno=2 二. 使用帶比較運(yùn)算的子查詢4. 查詢比劉晨年齡小的所有學(xué)生的信息:select * from student where sage (select sage from student where sname=劉晨)三. 使用帶any, all謂詞的子查詢5. 查詢其他系中比信息系(is)某一學(xué)生年齡小的學(xué)生姓名和年齡;select sname, sage from student where sage any (select sag
5、e from student where sdept=is) and sdeptis6. 查詢其他系中比信息系(is)學(xué)生年齡都小的學(xué)生姓名和年齡:select sname, sage from student where sage all(select sage from student where sdept=is) and sdeptis7. 查詢與計(jì)算機(jī)系(cs)系所有學(xué)生的年齡均不同的學(xué)生學(xué)號(hào), 姓名和年齡:select sno,sname,sage from student where sageall(select sage from student where sdept=cs)
6、四. 使用帶exists謂詞的子查詢和相關(guān)子查詢8. 查詢與其他所有學(xué)生年齡均不同的學(xué)生學(xué)號(hào), 姓名和年齡:select sno,sname,sage from student a where not exists(select * from student b where a.sage=b.sage and a.snob.sno) 9. 查詢所有選修了1號(hào)課程的學(xué)生姓名:select sname from student where exists(select * from sc where sno=student.sno and cno=1)10. 查詢沒(méi)有選修了1號(hào)課程的學(xué)生姓名:sel
7、ect sname from student where not exists(select * from sc where sno=student.sno and cno=1)11. 查詢選修了全部課程的學(xué)生姓名:sql server中: select sname from student where not exists(select * from course where not exists( select * from sc where sno=student.sno and cno=o)11. 查詢至少選修了學(xué)生95002選修的全部課程的學(xué)生的學(xué)號(hào):sql server中:sele
8、ct distinct sno from sc a where not exists (select * from sc b where sno=95002and not exists(select * from sc c where sno=a.sno and cno=b.cno)12. 求沒(méi)有人選修的課程號(hào)cno和cnamecname:select cno,cname from course c where not exists(select * from sc where o=c.cno )13*. 查詢滿足條件的(sno,cno)對(duì), 其中該學(xué)號(hào)的學(xué)生沒(méi)有選修該課程號(hào)cno的課程sql server中:select sno,cno from student,course where not exists(select * from sc where cno=o and sno=student.sno)14*. 查詢每個(gè)學(xué)生的課程成績(jī)最高的成績(jī)信息(sno,cno,grade):select * from sc a where grade=(select max(g
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2023年厚膜工藝電源資金需求報(bào)告
- 長(zhǎng)期護(hù)理保險(xiǎn)定點(diǎn)失能等級(jí)評(píng)估機(jī)構(gòu)服務(wù)協(xié)議范本(試行)
- 2024年差壓變送器項(xiàng)目投資申請(qǐng)報(bào)告代可行性研究報(bào)告
- 2024年鹿泉市一級(jí)造價(jià)工程師《土建計(jì)量》高分通關(guān)卷含解析
- 2024安徽租房合同范本
- 2024司法考試民法學(xué)講義買賣合同
- 2024年人行道養(yǎng)護(hù)車項(xiàng)目建議書
- 2024固定資產(chǎn)轉(zhuǎn)讓合同范本
- 2024年醫(yī)學(xué)研究與試驗(yàn)發(fā)展服務(wù)項(xiàng)目發(fā)展計(jì)劃
- 2024年數(shù)控刃磨床項(xiàng)目合作計(jì)劃書
- 2024統(tǒng)編新版小學(xué)五年級(jí)語(yǔ)文上冊(cè)第六單元 大單元整體教學(xué)設(shè)計(jì)
- 2024年全國(guó)軟件水平考試之初級(jí)程序員考試黑金試題附答案
- 2024年4月貴州省自考03035有機(jī)化學(xué)四試題及答案含評(píng)分參考
- 2024年高考化學(xué)河北卷試卷評(píng)析暨2025屆高考化學(xué)備考策略
- 幼兒園大班藝術(shù)課件:《國(guó)旗國(guó)旗紅紅的哩》
- JTG-D40-2011公路水泥混凝土路面設(shè)計(jì)規(guī)范
- 個(gè)人財(cái)產(chǎn)申報(bào)表(簡(jiǎn))
- 網(wǎng)絡(luò)安全設(shè)備巡檢記錄表
- 水平二田徑大單元
- 道路清障救援作業(yè)服務(wù)道路清障救援實(shí)施方案
- 醫(yī)療廢物處置管理?xiàng)l例
評(píng)論
0/150
提交評(píng)論