




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
實(shí)驗(yàn)三:數(shù)據(jù)庫的嵌套查詢實(shí)驗(yàn)實(shí)驗(yàn)?zāi)康模杭由顚?duì)嵌套查詢語句的理解。實(shí)驗(yàn)內(nèi)容:使用IN、比擬符、ANY或ALL和EXISTS操作符進(jìn)行嵌套查詢操作。實(shí)驗(yàn)步驟:一.使用帶IN謂詞的子查詢1.查詢與’劉晨’在同一個(gè)系學(xué)習(xí)的學(xué)生的信息:比擬select*fromstudentwheresdeptin(selectsdeptfromstudentwheresname='劉晨')與:select*fromstudentwheresdept=(selectsdeptfromstudentwheresname='劉晨')的異同比擬:select*fromstudentwheresdept=(selectsdeptfromstudentwheresname='劉晨')andsname<>‘劉晨’與:selectS1.*fromstudentS1,studentS2whereS1.sdept=S2.sdeptandS2.sname='劉晨'的異同2.查詢選修了課程名為’信息系統(tǒng)’的學(xué)生的學(xué)號(hào)和姓名:比擬selectsno,snamefromstudentwheresnoin(selectsnofromscwherecnoin(selectcnofromcoursewherecname='信息系統(tǒng)'))與:selectsno,snamefromstudentwheresnoin(selectsnofromsc,coursewheresco=courseoandcname='信息系統(tǒng)')3.查詢選修了課程’1’和課程’2’的學(xué)生的學(xué)號(hào):selectsnofromstudentwheresnoin(selectsnofromscwherecno='1')andsnoin(selectsnofromscwherecno='2')比擬:查詢選修了課程’1’或課程’2’的學(xué)生的sno:selectsnofromscwherecno='1'orcno='2'比擬連接查詢:selectA.snofromscA,scBwhereA.sno=B.snoandAo='1'andBo='2'二.使用帶比擬運(yùn)算的子查詢
4.查詢比’劉晨’年齡小的所有學(xué)生的信息:select*fromstudentwheresage<(selectsagefromstudentwheresname='劉晨')三.使用帶Any,All謂詞的子查詢5.查詢其他系中比信息系(IS)某一學(xué)生年齡小的學(xué)生姓名和年齡;selectsname,sagefromstudentwheresage<Any(selectsagefromstudentwheresdept='IS')andsdept<>'IS'6.查詢其他系中比信息系(IS)學(xué)生年齡都小的學(xué)生姓名和年齡:selectsname,sagefromstudentwheresage<ALL(selectsagefromstudentwheresdept='IS')andsdept<>'IS'7.查詢與計(jì)算機(jī)系(CS)系所有學(xué)生的年齡均不同的學(xué)生學(xué)號(hào),姓名和年齡:selectsno,sname,sagefromstudentwheresage<>all(selectsagefromstudentwheresdept='CS')四.使用帶Exists謂詞的子查詢和相關(guān)子查詢8.查詢與其他所有學(xué)生年齡均不同的學(xué)生學(xué)號(hào),姓名和年齡:selectsno,sname,sagefromstudentAwherenotexists
(select*fromstudentBwhereA.sage=B.sageandA.sno<>B.sno)9.查詢所有選修了1號(hào)課程的學(xué)生姓名:selectsnamefromstudentwhereexists(select*fromscwheresno=student.snoandcno='1')10.查詢沒有選修了1號(hào)課程的學(xué)生姓名:selectsnamefromstudentwherenotexists(select*fromscwheresno=student.snoandcno='1')11.查詢選修了全部課程的學(xué)生姓名:SQLServer中:selectsnamefromstudentwherenotexists(select*fromcoursewherenotexists(select*fromscwheresno=student.snoandcno=courseo))11.查詢至少選修了學(xué)生95002選修的全部課程的學(xué)生的學(xué)號(hào):SQLServer中:selectdistinctsnofromscAwherenotexists(select*fromscBwheresno='95002'andnotexists(select*fromscCwheresno=A.snoandcno=Bo))12.求沒有人選修的課程號(hào)cno和cnamecname:selectcno,cnamefromcourseCwherenotexists(select*fromscwheresco=Co)13*.查詢滿足條件的(sno,cno)對(duì),其中該學(xué)號(hào)的學(xué)生沒有選修該課程號(hào)cno的課程SQLServer中:selectsno,cnofromstudent,coursewherenotexists(select*fromscwherecno=courseoandsno=student.sno)14*.查詢每個(gè)學(xué)生的課程成績(jī)最高的成績(jī)信息(sno,cno,grade):select*fromscAwheregrade=(select
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五私企員工勞動(dòng)合同與員工績(jī)效評(píng)估
- 2025年度無產(chǎn)權(quán)車庫轉(zhuǎn)讓及附屬綠化帶使用協(xié)議
- 二零二五年度科技型企業(yè)融資合作框架
- 2025年度礦山股份合作保險(xiǎn)合同:礦山安全生產(chǎn)責(zé)任險(xiǎn)與財(cái)產(chǎn)險(xiǎn)合作協(xié)議
- 二零二五年度城市軌道交通工程用工管理協(xié)議
- 2025年度首飾抵押借款合同購買設(shè)計(jì)師首飾服務(wù)協(xié)議
- 2025年手房購房合同(含車位及儲(chǔ)藏室)
- 【央企招聘】中煤電力有限公司所屬企業(yè)公開招聘(24人)筆試參考題庫附帶答案詳解
- 2025遼寧鞍山市臺(tái)安農(nóng)業(yè)發(fā)展集團(tuán)有限公司招聘11人筆試參考題庫附帶答案詳解
- 2025福建投資集團(tuán)能源板塊去場(chǎng)招聘114人筆試參考題庫附帶答案詳解
- 2025年健身教練合同協(xié)議樣本
- 2025年常州工業(yè)職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(培優(yōu))
- 2025年湖南商務(wù)職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫必考題
- 中儲(chǔ)糧黑龍江分公司招聘考試試卷2023
- 化學(xué)實(shí)驗(yàn)室安全職責(zé)分配
- 1.2 讀懂彼此的心 第二課時(shí) 課件 2024-2025學(xué)年五年級(jí)下冊(cè)道德與法治 統(tǒng)編版
- 2018-2022年北京市中考真題數(shù)學(xué)試題匯編:選擇壓軸(第8題)
- 2025年哈爾濱鐵道職業(yè)技術(shù)學(xué)院高職單招語文2018-2024歷年參考題庫頻考點(diǎn)含答案解析
- 2025年貴州黔源電力股份有限公司招聘筆試參考題庫含答案解析
- 2024年湖南食品藥品職業(yè)學(xué)院高職單招語文歷年參考題庫含答案解析
- 《船舶油漆作業(yè)》課件
評(píng)論
0/150
提交評(píng)論