真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

如何使用SQL語(yǔ)句實(shí)現(xiàn)表的查詢

這篇文章主要介紹“如何使用SQL語(yǔ)句實(shí)現(xiàn)查詢”,在日常操作中,相信很多人在如何使用SQL語(yǔ)句實(shí)現(xiàn)查詢問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”如何使用SQL語(yǔ)句實(shí)現(xiàn)查詢”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

目前累計(jì)服務(wù)客戶成百上千家,積累了豐富的產(chǎn)品開發(fā)及服務(wù)經(jīng)驗(yàn)。以網(wǎng)站設(shè)計(jì)水平和技術(shù)實(shí)力,樹立企業(yè)形象,為客戶提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)絡(luò)營(yíng)銷、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。成都創(chuàng)新互聯(lián)公司始終以務(wù)實(shí)、誠(chéng)信為根本,不斷創(chuàng)新和提高建站品質(zhì),通過對(duì)領(lǐng)先技術(shù)的掌握、對(duì)創(chuàng)意設(shè)計(jì)的研究、對(duì)客戶形象的視覺傳遞、對(duì)應(yīng)用系統(tǒng)的結(jié)合,為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。


大家都知道SQL是結(jié)構(gòu)化查詢語(yǔ)言,是關(guān)系數(shù)據(jù)庫(kù)的標(biāo)準(zhǔn)語(yǔ)言,是一個(gè)綜合的,功能極強(qiáng)的同時(shí)又簡(jiǎn)潔易學(xué)的,它集級(jí)數(shù)據(jù)查詢(Data Quest),數(shù)據(jù)操縱(Data Manipulation),數(shù)據(jù)定義(Data Definition),數(shù)據(jù)控制(Data Control)于一體 即:
SQL語(yǔ)言包含4個(gè)部分:
※ 數(shù)據(jù)定義語(yǔ)言(DDL),例如:CREATE、DROP、ALTER等語(yǔ)句
※ 數(shù)據(jù)操作語(yǔ)言(DML),例如:INSERT(插入)、UPDATE(修改)、DELETE(刪除)語(yǔ)句
※ 數(shù)據(jù)查詢語(yǔ)言(DQL),例如:SELECT語(yǔ)句
※ 數(shù)據(jù)控制語(yǔ)言(DCL),例如:GRANT、REVOKE、COMMIT、ROLLBACK等語(yǔ)句
SQL語(yǔ)言包括三種主要程序設(shè)計(jì)語(yǔ)言類別的語(yǔ)句:數(shù)據(jù)定義語(yǔ)言(DDL),數(shù)據(jù)操作語(yǔ)言(DML)及數(shù)據(jù)控制語(yǔ)言(DCL)
現(xiàn)在說說SQL的幾個(gè)基本概念:
基本表:本身獨(dú)立存在的一個(gè)表,一個(gè)關(guān)系就是對(duì)應(yīng)一個(gè)基本表
內(nèi)模式:存儲(chǔ)文件的邏輯結(jié)構(gòu)組成了關(guān)系數(shù)據(jù)庫(kù)的內(nèi)模式
視圖:從一個(gè)或幾個(gè)基本表導(dǎo)出的表,他是一個(gè)虛表
簡(jiǎn)單實(shí)踐
建一個(gè)數(shù)據(jù)庫(kù),包含“學(xué)生表”,“教員表”,“任課表”,“專業(yè)表”,“課程表”,“學(xué)生個(gè)人情況表”,“成績(jī)表”七張表
下面幾個(gè)表是我們這次實(shí)踐要用到的表: 用SQL語(yǔ)句建表:
建立一個(gè)數(shù)據(jù)庫(kù)cc

復(fù)制代碼 代碼如下:


create database cc;
use cc;


創(chuàng)建一個(gè)名為tb_student的學(xué)生表

復(fù)制代碼 代碼如下:


tb_student的學(xué)生表
create table tb_student(
stunum char(7) primary key, --學(xué)號(hào)
stuname char(8) not null, --姓名
stusex char(2) check(stusex in('女','男')), --性別
stubirthday smalldatetime not null, --學(xué)生出生日期
stuspec char(6)not null, --專業(yè)
stuscore numeric(4,1), --入學(xué)成績(jī)
stuloan char(2) check(stuloan in ('是','否'))not null, --是否貸款
)


創(chuàng)建一個(gè)名為tb_teacher的教師表
tb_teacher的教師表

復(fù)制代碼 代碼如下:


create table tb_teacher(
教師代號(hào) char(7) primary key, --教師代號(hào)
姓名 char(8) not null, --教師名字
性別char(2) check(teasex in('女','男')), --教師性別
出生年月 datetime not null, --教師出生日期
職稱 char(6), --職稱
)



創(chuàng)建一個(gè)名為tb_renke的任課表

tb_renke的任課表

復(fù)制代碼 代碼如下:


create table tb_renke(
課程代號(hào) char(5), --課程代號(hào)
教師代號(hào) char(7), -- 教師代號(hào)
)



創(chuàng)建一個(gè)名為tb_major的專業(yè)表

復(fù)制代碼 代碼如下:


tb_major的專業(yè)表
create tabletb_major(
專業(yè)名稱 char(8) primary key, --專業(yè)名稱
負(fù)責(zé)人 char(8) not null, --負(fù)責(zé)人
)



創(chuàng)建一個(gè)名為tb_course的課程表

復(fù)制代碼 代碼如下:


tb_course的課程表
create table course(
課程代號(hào) char(5)primary key, --課程代號(hào)
課程名 char(14) not null, --課程名
周學(xué)時(shí) int, --周學(xué)時(shí)
學(xué)分 int, --學(xué)分
)


創(chuàng)建一個(gè)名為tb_studentinfo的學(xué)生個(gè)人情況表

tb_studentinfo的學(xué)生個(gè)人情況表

復(fù)制代碼 代碼如下:


create table tb_studentinfo(
學(xué)號(hào) char(7), --學(xué)號(hào)
身份證 char(15) unique, --身份證號(hào)碼
籍貫 char(8), --籍貫
家庭住址 text, --家庭住址
電話 char(30), --電話
特長(zhǎng) text, --特長(zhǎng)
獎(jiǎng)勵(lì) text, --獎(jiǎng)勵(lì)
處分 char(100), --處分
)



創(chuàng)建一個(gè)名為tb_grade的成績(jī)表

tb_grade的成績(jī)表

復(fù)制代碼 代碼如下:


create table tb_grade(
學(xué)號(hào) char(7), --學(xué)號(hào)
課程代號(hào) char(5), --課程代號(hào)
平時(shí) numeric(3,1), --平時(shí)
期中 numeric(3,1), --期中
期末 numeric(3,1), --期末
)



現(xiàn)在向每一張表插入記錄
給學(xué)生表tb_student插入數(shù)據(jù)

復(fù)制代碼 代碼如下:


tb_student
insert into tb_student values('9607039','鄧盈瑩','女','1978-6-6','外貿(mào)',666.6,'是');
insert into tb_student values('9907002','倪雯嫻','女','1981-4-1','外貿(mào)',641.4,'是');
insert into tb_student values('9801055','趙東','男','1979-11-9','中文',450,'否');
insert into tb_student values('9902006','和音','女','1982-6-19','數(shù)學(xué)',487.1,'否');
insert into tb_student values('9704001','克敏敏','女','1978-7-22','物理',463,'否');
insert into tb_student values('9603001','申強(qiáng)','男','1978-1-15','新聞',512,'是');
insert into tb_student values('9606005','遲大為','男','1976-9-3','化學(xué)',491.3,'否');
insert into tb_studentvalues('9803011','歐陽(yáng)小娟','女','1981-8-11','新聞',526.5,'否');
insert into tb_student values('9908088','毛杰','男','1982-1-1','計(jì)算機(jī)',622.2,'否');
insert into tb_student values('9608066','康紅','女','1979-9-7','計(jì)算機(jī)',596.8,'是');
insert into tb_student values('9805026','夏天','男','1980-5-7','歷史',426.7,'否');
insert into tb_student values('9702033','李力','男','1979-7-7','數(shù)學(xué)',463.9,'否');



給教師表tb_teacher插入數(shù)據(jù)

復(fù)制代碼 代碼如下:


tb_teacher
insert into tb_teacher values('20222','于朵','女','1962-6-19','副教授');
insert into tb_teacher values('20406','張建','女','1946-7-16','教授');
insert into tb_teacher values('10429','蔣成功','男','1959-3-12','副教授');
insert into tb_teacher values('10616','萬(wàn)年','男','1945-9-1','教授');
insert into tb_teacher values('20626','孫樂','女','1971-12-15','講師');
insert into tb_teacher values('10803','李鐵','男','1958-9-22','副教授');
insert into tb_teacher values('10812','米粟','男','1960-1-3','副教授');
insert into tb_teacher values('11015','柴淮','男','1973-8-26','講師');
insert into tb_teacher values('11107','方華','女','197**-6','講師');
insert into tb_teacher values('20836','張靜','女','1974-11-15','講師');
insert into tb_teacher values('10101','高樹聲','男','1940-12-5','教授');
insert into tb_teacher values('10312','鞏文','男','1959-3-17','副教授');
insert into tb_teacher values('20506','吳燕','女','1947-10-6','教授');
insert into tb_teacher values('20701','沈菲菲','女','1960-6-18','副教授');
insert into tb_teacher values('10202','梁龍林','男','1948-6-18','教授');
insert into tb_teacher values('10428','李陽(yáng)','男','1955-8-12','教授');
insert into tb_teacher values('10621','魯師','男','1943-11-18','教授');
insert into tb_teachervalues('10809','鄧為民','男','1957-1-26','副教授');
insert into tb_teacher values('20106','姜曉紅','女','1961-6-5','副教授');
insert into tb_teacher values('10131','付林','男','1968-9-11','講師');
insert into tb_teacher values('10802','楊亮紅','男','1941-5-23','教授');
insert into tb_teacher values('10223','周毅','男','1970-3-8','講師');
insert into tb_teacher values('20255','孫莉莉','女','1975-9-12','講師');
insert into tb_teacher values('20705','夏雪','女','1969-10-28','講師');
insert into tb_teacher values('10712','南方','男','1975-9-13','講師');
insert into tb_teacher values('10201','代順達(dá)','男','1940-12-17','講師');
insert into tb_teacher values('20301','高珊','女','1965-6-19','副教授');
insert into tb_teacher values('20319','林妮','女','1973-4-1','講師');
insert into tb_teacher values('21025','張旗','女','1972-6-6','講師');
insert into tb_teacher values('11117','韓明','男','1976-2-14','助教');
insert into tb_teacher values('10503','孫建國(guó)','男','1949-10-1','教授');
insert into tb_teacher values('10509','黃寧','男','1956-12-23','副教授');



給任課表tb_renke插入數(shù)據(jù)

復(fù)制代碼 代碼如下:


tb_renke
insert into tb_renke values('21003','21025');
insert into tb_renke values('30211','20255');
insert into tb_renke values('30232','10201');
insert into tb_renke values('40711','10712');
insert into tb_renke values('40722','20701');
insert into tb_renke values('10101','20106');
insert into tb_renke values('11101','11107');
insert into tb_renke values('20511','10509');
insert into tb_renke values('10101','10131');
insert intotb_renke values('20534','10503');
insert into tb_renke values('10712','20705');
insert into tb_renke values('20115','20106');
insert into tb_renke values('10222','10223');
insert into tb_renke values('30412','10429');
insert into tb_renke values('40316','20319');
insert into tb_renke values('40612','20626');
insert into tb_renke values('20328','20301');
insert into tb_renke values('10812','10429');
insert into tb_renke values('20801','10803');
insert into tb_renke values('30802','10812');
insert into tb_renke values('11001','11015');
insert into tb_renke values('20113','10131');
insert into tb_renke values('30416','10428');
insert into tb_renke values('20327','10312');
insert into tb_renke values('20521','20506');
insert into tb_renke values('30213','10201');
insert into tb_renke values('11101','11117');
insert into tb_renke values('10715','20222');
insert intotb_renke values('20111','10101');
insert into tb_renke values('10218','10202');
insert intotb_renke values('30423','20406');
insert into tb_renke values('40331','20319');
insert intotb_renke values('40625','10616');
insert into tb_renke values('20314','20301');
insert into tb_renke values('10811','20836');
insert into tb_renke values('30819','10802');



給專業(yè)表tb_major插入數(shù)據(jù)

復(fù)制代碼 代碼如下:


tb_major
insert into tb_major values('化學(xué)','魯師');
insert into tb_major values('計(jì)算機(jī)','鄧為民');
insert into tb_major values('軟件','李明');
insert into tb_major values('外貿(mào)','沈菲菲');
insert into tb_major values('數(shù)學(xué)','梁龍林');
insert into tb_major values('物理','李陽(yáng)');
insert intotb_major values('物理學(xué)','王國(guó)玉');
insert into tb_major values('歷史','吳燕');
insert into tb_major values('中文','高樹聲');
insert into tb_major values('新聞','鞏文');


給課程表tb_course插入數(shù)據(jù)

復(fù)制代碼 代碼如下:


tb_course
insert into tb_course values('20511','世界近代史',4,4);
insert into tb_course values('10101','大學(xué)語(yǔ)文',2,2);
insert into tb_course values('20801','計(jì)算機(jī)基礎(chǔ)(一)',4,3);
insert into tb_course values('10218','高等代數(shù)',4,4);
insert into tb_course values('11001','英語(yǔ)(一)',6,6);
insert into tb_course values('20113','外國(guó)文學(xué)',4,4);
insert into tb_course values('30416','接口技術(shù)',4,3);
insert into tb_course values('20327','報(bào)刊編輯學(xué)',2,2);
insert into tb_course values('20521','中國(guó)民族史',3,2);
insert into tb_course values('30213','數(shù)論',4,4);
insert into tb_course values('11101','體育',2,2);
insert into tb_course values('21003','英語(yǔ)(二)',4,4);
insert into tb_course values('10715','高等數(shù)學(xué)',4,4);
insert into tb_course values('20111','古代漢語(yǔ)',3,3);
insert into tb_course values('30802','計(jì)算機(jī)基礎(chǔ)(二)',3,3);
insert into tb_course values('30423','電磁場(chǎng)理論',3,3);
insert into tb_course values('40331','傳播心理學(xué)',2,2);
insert into tb_course values('40625','色譜學(xué)',2,2);
insert into tb_course values('20314','新聞學(xué)概論',2,2);
insert into tb_course values('10811','離散數(shù)學(xué)',2,2);
insert into tb_course values('30819','編譯技術(shù)',4,4);
insert into tb_course values('20534','中國(guó)近代史',4,4);
insert into tb_course values('10712','政治經(jīng)濟(jì)學(xué)',3,3);
insert into tb_course values('20115','近代漢語(yǔ)',4,4);
insert into tb_course values('30211','概論統(tǒng)計(jì)',3,3);
insert into tb_course values('30232','數(shù)學(xué)分析',2,2);
insert into tb_course values('40711','國(guó)際投資學(xué)',2,2);
insert into tb_course values('40722','國(guó)際商法',2,2);
insert into tb_course values('30832','算法設(shè)計(jì)',4,4);
insert into tb_course values('10812','數(shù)字電路',4,4);
insert into tb_course values('10222','解析幾何',2,2);
insert into tb_course values('30412','近代物理實(shí)驗(yàn)',3,2);
insert into tb_course values('40316','當(dāng)代新聞史',2,2);
insert into tb_course values('40612','配位化學(xué)',3,3);
insert into tb_course values('20328','現(xiàn)代新聞報(bào)道',4,4);



給學(xué)生個(gè)人情況表tb_studentinfo插入數(shù)據(jù)

復(fù)制代碼 代碼如下:


tb_studentinfo
insert into tb_studentinfo values('9607039','530120169021101','安徽','江岸小區(qū)棟單元','5033228','唱歌,摔跤','被評(píng)為三好學(xué)生','');
insert into tb_studentinfo values('9907002','530120170060701','云南','江岸小區(qū)棟單元','5033226','跳舞,籃球','被評(píng)為三好學(xué)生','');
insert into tb_studentinfo values('9801055','530120171072501','湖北','白馬小區(qū)棟單元','4133224','圍棋','','');
insert into tb_studentinfo values('9902006','530120170122901','湖南','金星小區(qū)棟單元','3133218','象棋','被評(píng)為三好學(xué)生','');
insert into tb_studentinfo values('9704001','530120168121101','云南','靜園小區(qū)棟單元','2133227','排球,足球','','');
insert into tb_studentinfo values('9603001','530120174050101','云南','江岸小區(qū)棟單元','5033219','唱歌,跳舞','被評(píng)為紅花少年','');
insert into tb_studentinfo values('9606005','530120175040702','江蘇','江岸小區(qū)棟單元','5033123','演講','','');
insert into tb_studentinfo values('9803011','530120173021201','四川','白馬小區(qū)棟單元','4133124','集郵','獲集郵展三等獎(jiǎng)','');
insert into tb_studentinfo values('9908088','530120172092801','四川','陽(yáng)光小區(qū)棟單元','3133177','長(zhǎng)跑足球','獲省長(zhǎng)跑第二名','作弊受處分');
insert into tb_studentinfo values('9608066','530120174092201','云南','陽(yáng)光小區(qū)棟單元','3133222','攝影','獲優(yōu)秀作文獎(jiǎng)','');
insert into tb_studentinfo values('9805026','530120174110901','貴州','陽(yáng)光小區(qū)棟單元','3133189','圍棋','獲數(shù)學(xué)競(jìng)賽一等獎(jiǎng)','');
insert into tb_studentinfo values('9702033','530120170080401','黑龍江','陽(yáng)光小區(qū)棟單元','3148212','圍棋','獲數(shù)學(xué)競(jìng)賽三等獎(jiǎng)','');


給成績(jī)表tb_grade插入數(shù)據(jù)

復(fù)制代碼 代碼如下:


tb_grade
insert into tb_grade values('9805026','20801',75,87,82);
insert into tb_grade values('9702033','30802',80,89,91);
insert into tb_grade values('9907002','11001',91,83,85);
insert into tb_grade values('9801055','20113',70,65,55);
insert into tb_grade values('9607039','40711',85,80,88);
insert into tb_grade values('9907002','10715',83,90,86);
insert into tb_grade values('9801055','20111',78,60,65);
insert into tb_grade values('9902006','10218',75,63,52);
insert into tb_grade values('9902006','11001',78,86,81);
insert into tb_grade values('9704001','30416',80,90,90);
insert into tb_grade values('9803011','20327',95,93,90);
insert into tb_grade values('9908088','11001',90,91,87);
insert into tb_grade values('9805026','20521',90,97,96);
insert into tb_grade values('9702033','30213',88,69,76);
insert into tb_grade values('9907002','11101',88,65,72);
insert into tb_grade values('9801055','21003',70,90,84);
insert into tb_grade values('9902006','11101',80,70,70);
insert into tb_grade values('9803011','21003',78,84,82);
insert into tb_grade values('9908088','11101',82,75,78);
insert into tb_grade values('9805026','21003',83,85,84);
insert into tb_grade values('9805026','20511',90,82,86);
insert into tb_grade values('9702033','30232',80,84,83);
insert into tb_grade values('9907002','10101',84,96,92);
insert into tb_grade values('9801055','20801',76,78,60);
insert into tb_grade values('9902006','10101',85,88,81);
insert into tb_grade values('9704001','30802',90,87,82);
insert into tb_grade values('9803011','20801',60,50,51);
insert into tb_grade values('9704001','30423',80,81,85);
insert into tb_grade values('9603001','40331',67,72,70);
insert into tb_grade values('9606005','40625',83,85,84);
insert into tb_grade values('9803011','20314',76,76,76);
insert into tb_grade values('9908088','10811',82,92,89);
insert into tb_grade values('9608066','30819',78,84,82);
insert into tb_grade values('9805026','20534',70,90,84);
insert into tb_grade values('9702033','30211',93,89,90);
insert into tb_grade values('9607039','40722',90,87,82);
insert into tb_grade values('9907002','10712',90,96,97);
insert into tb_grade values('9801055','20115',80,82,87);
insert into tb_grade values('9902006','10222',85,91,79);
insert into tb_grade values('9704001','30412',78,87,90);
insert into tb_grade values('9603001','30316',66,71,73);
insert into tb_grade values('9606005','40612',70,78,60);
insert into tb_grade values('9803011','20328',90,88,87);
insert into tb_grade values('9908088','10812',80,67,83);
insert into tb_grade values('9608066','30832',95,92,93);
insert into tb_grade values('9908088','10101',80,82,87);


下面進(jìn)行數(shù)據(jù)查詢:


(1)查詢?cè)?8年12月31日之后出生的學(xué)生的學(xué)號(hào)和姓名
思考一下在展開
select學(xué)號(hào),姓名from tb_student where 出生年月>'1979';
或是:
select學(xué)號(hào),姓名from tb_student where 出生年月>cast('1978-12-31' as datetime);
(2)查詢?nèi)雽W(xué)成績(jī)大于500分的女同學(xué)和入學(xué)成績(jī)大于600分的男同學(xué)的姓名
思考一下在展開
select姓名from tb_student where (入學(xué)成績(jī)>500 and 性別='女')or(入學(xué)成績(jī)>600 and 性別='男') ;
(3)查詢家在江岸小區(qū)住的學(xué)生的姓名和家庭住址
思考一下在展開
select家庭住址,姓名from tb_studentinfo,tb_student where( 家庭住址like'江岸小區(qū)%')and (tb_studentinfo.學(xué)號(hào)=tb_student.學(xué)號(hào)) ;
(4)查詢沒有選修姜曉紅老師所授課程的學(xué)生的學(xué)號(hào)
思考一下在展開
select學(xué)號(hào)from tb_student where 學(xué)號(hào)not in(select 學(xué)號(hào)from tb_grade,tb_teacher,tb_renke where tb_grade.課程代號(hào)=tb_renke.課程代號(hào)and tb_renke.教師代號(hào)=tb_teacher.教師代號(hào)and姓名='姜曉紅' );
(5)查詢各學(xué)生所選課的期末平均成績(jī),學(xué)生學(xué)號(hào),姓名
思考一下在展開
select tb_student.姓名,tb_grade.學(xué)號(hào),avg(期末) from tb_student,tb_grade where tb_student.學(xué)號(hào)=tb_grade.學(xué)號(hào)group by tb_student.姓名,tb_grade.學(xué)號(hào);
(6)查詢趙東所選修的課程的課程名及其學(xué)號(hào)、姓名
思考一下在展開
select tb_student.姓名,tb_grade.學(xué)號(hào),課程名from tb_student,tb_grade ,tb_course where tb_grade.學(xué)號(hào)=tb_student.學(xué)號(hào)and tb_grade.課程代號(hào)=tb_Course.課程代號(hào)and姓名='趙東';
(7)查詢由教授所任課的課程名
思考一下在展開
select課程名from tb_course,tb_teacher ,tb_renke where tb_course.課程代號(hào)=tb_renke.課程代號(hào)and tb_teacher.教師代號(hào)=tb_renke.教師代號(hào)and職稱='教授'
或是:
select課程名from tb_course where 課程代號(hào)in (select 課程代號(hào)from tb_renke where 教師代號(hào)in(select教師代號(hào)from tb_teacher where 職稱='教授'));
(8)統(tǒng)計(jì)沒有貸款的學(xué)生的人數(shù)
思考一下在展開
select count(*)沒貸款的人數(shù)from tb_student where 是否貨款='false';
(9)查詢每個(gè)科目平時(shí)、期中及期末三個(gè)成績(jī)的平均成績(jī)?cè)?0分以上的學(xué)生的學(xué)號(hào)
思考一下在展開
select學(xué)號(hào)成績(jī)平均在分以上的學(xué)號(hào)from tb_grade group by 學(xué)號(hào)having avg(平時(shí)+期中+期末)>80;
(10)查詢和毛杰同學(xué)所學(xué)專業(yè)一樣的人的學(xué)號(hào)和姓名
思考一下在展開
select學(xué)號(hào),姓名from tb_student where 專業(yè)in (select 專業(yè)from tb_student where 姓名='毛杰');

(11)查詢期末成績(jī)大于任何一個(gè)老師所教學(xué)生的期末成績(jī)的學(xué)生姓名、選修課程號(hào)、成績(jī)
思考一下在展開
select 姓名,課程代號(hào),期末,tb_grade.學(xué)號(hào)from tb_grade,tb_student where tb_student.學(xué)號(hào)=tb_grade.學(xué)號(hào)and 期末>=all(select 期末from tb_grade);

(12)來了一位新同學(xué),學(xué)號(hào)為9607001,省份證號(hào)為530120169021100
思考一下在展開
insert into tb_studentinfo (學(xué)號(hào),身份證)values('9607001','530120169021100');
insert into tb_student(學(xué)號(hào))values('9607001');
(13)將期末成績(jī)?cè)谒腥说钠谀┢骄煽?jī)以上的同學(xué)加10分

思考一下在展開
update tb_grade set 期末=期末+10 where 期末>(select avg(期末) from tb_grade);

(14)查詢至少選修了付林老師所授所有課程的學(xué)生學(xué)號(hào)
思考一下在展開
Select學(xué)號(hào)from tb_grade x Where not exists (select * from tb_grade y Where 教師代號(hào)in( Select 教師代號(hào)from tb_teacher,tb_renke Where 姓名='付林'and tb_teacher.教師代號(hào)=tb_renke.教師代號(hào)) And not exists(select *from tb_grade z Where z.課程代號(hào)=y.課程代號(hào)and z.學(xué)號(hào)=x.學(xué)號(hào)))

(15)統(tǒng)計(jì)每個(gè)老師授課的種數(shù)
思考一下在展開
select教師代號(hào),count(*)課程種數(shù)from tb_renke group by tb_renke.教師代號(hào);
(16)查詢選修2門以上課程的學(xué)生學(xué)號(hào)及平均成績(jī)(指各課程的期末成績(jī)的平均成績(jī),只統(tǒng)計(jì)及格的課程),并按其平均成績(jī)降序排列輸出
思考一下在展開
select 學(xué)號(hào),avg(期末)平均分from tb_grade where 期末> 60 group by 學(xué)號(hào)having count(*)>2 order by avg( 期末)desc;
(17)查詢沒有貸款的學(xué)生的學(xué)號(hào)
思考一下在展開
select學(xué)號(hào)沒貸款的學(xué)號(hào)from tb_student where 是否貨款='false';
(18)查詢年齡最大的學(xué)生的學(xué)號(hào)和姓名

思考一下在展開
select學(xué)號(hào),姓名from tb_student where 出生年月in ( select min(出生年月) from tb_student );

到此,關(guān)于“如何使用SQL語(yǔ)句實(shí)現(xiàn)查詢”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!


網(wǎng)站題目:如何使用SQL語(yǔ)句實(shí)現(xiàn)表的查詢
網(wǎng)站鏈接:http://weahome.cn/article/jecdog.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部