Set @dlr = 15001;
SELECT school.name AS schoolName, xq.xqmc AS xqmc, qy.mc as qymc, ly.bz as lymc, fj.bz as fjmc FROM t_xsgy_ssap ssap
LEFT JOIN t_xsgy_cwgl cwgl ON cwgl.id=ssap.cwid
LEFT JOIN t_baseinfo_fj fj ON fj.id = cwgl.fj
LEFT JOIN t_baseinfo_ly ly ON fj.lyid = ly.id
LEFT JOIN t_baseinfo_qy qy ON ly.qyid = qy.id
LEFT JOIN t_sys_school school ON ssap.ssxxid = school.id
LEFT JOIN t_baseinfo_xq xq ON qy.ssxq = xq.id
WHERE ssap.xhid = @dlr
AND ssap.zszt =1