場景
在查詢學生信息中,允許學生宿舍信息為空,如果有獲取,沒有為空
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
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。