第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

多表查詢。。。。。。

標(biāo)簽:
MySQL

三、多表查询:连接查询
select tb_student.sname, tb_student.sage,tb_score.sclassname, tb_score.sscore
from tb_student, tb_score
where tb_student.sno = tb_score.sno
=> 精简代码,给表取别名
select a.sname, a.sage,b.sclassname, b.sscore
from tb_student a, tb_score b
where a.sno = b.sno
三表等值连接:
查询学生的成绩表,要求显示学生学号,姓名,性别,课程名和成绩
学号,姓名,性别 来源于 tb_student
课程名 —— tb_class
成绩 ——— tb_score
select a.sno, a.sname,a.ssex,c.cname,b.sscore
from tb_student a, tb_score b, tb_class c
where a.sno = b.sno
and b.cno = c.cno;
四、子查询:
在where子句中,值使用一个查询语句替代
请查询考试成绩大于70分的学生,显示学生编号,姓名和专业
分析:
1、考试成绩大于70分有哪些学生,数据来源于成绩表
可以查出符合条件的学生编号
2、根据第一步的结果,再查询学生表的信息
1、查询成绩大于70分的学号
select distinct sno
from tb_score
where sscore > 70
2、根据学号列表,找姓名和专业
--子查询实现
select sno, sname, sdept
from tb_student
where sno IN(
select distinct sno
from tb_score
where sscore > 70
)
也可以用连接查询实现:
select distinct a.sno, a.sname, a.sdept
from tb_student a, tb_score b
where a.sno = b.sno
and b.sscore > 70;

點擊查看更多內(nèi)容
2人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學(xué)

大額優(yōu)惠券免費領(lǐng)

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消