成都创新互联网站制作重庆分公司

MySQL第七课leftjoin左连接

场景

创新互联专注于阿拉尔网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供阿拉尔营销型网站建设,阿拉尔网站制作、阿拉尔网页设计、阿拉尔网站官网定制、微信小程序定制开发服务,打造阿拉尔网络公司原创品牌,更为您提供阿拉尔网站排名全网营销落地服务。

        在查询学生信息中,允许学生宿舍信息为空,如果有获取,没有为空

select t.*, cs_sc_studenthostel.name as hostelname
from (
select cs_sc_student.id as student_id,
cs_sc_student.name as studentname,  
cs_sc_class.name as classname, 
cs_sc_student.sc_studenthostel_id  
from cs_sc_student, cs_sc_class 
where cs_sc_student.sc_class_id = cs_sc_class.id) t
left join cs_sc_studenthostel on t.sc_studenthostel_id = cs_sc_studenthostel.id

第一步 获取到学生的基础信息

(
select cs_sc_student.id as student_id,
cs_sc_student.name as studentname,  
cs_sc_class.name as classname, 
cs_sc_student.sc_studenthostel_id  
from cs_sc_student, cs_sc_class 
where cs_sc_student.sc_class_id = cs_sc_class.id) t

第二步 进行左连接

left join cs_sc_studenthostel on t.sc_studenthostel_id = cs_sc_studenthostel.id


当前名称:MySQL第七课leftjoin左连接
网站路径:http://cxhlcq.com/article/jegsjd.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部