日期:2014-05-18  浏览次数:20710 次

麻烦各位老师给看看这条SQL语句的问题出在哪里?!
select distinct a.diqu,a.kahao,a.CheckInNo,a.piaolei,a.ZhengJian,a.CheckInTime,a.RenShu,b.mingcheng,c.mingma,d.mingcheng as mch,e.mingcheng as pl,f.DFMingCheng as zj,g.Expr1 as cf from(select k.CheckInTime,k.RenShu,k.diqu,k.kahao,k.checkinno,k.piaolei,k.ZhengJian from Tbl_checkIn k,(select max(id) as id,zhengjian from Tbl_checkIn group by zhengjian) b where k.id=b.id) a,tbl_diqu b,tbl_ShouPiao c,tbl_YanPiaoDian d,tbl_PiaoLei e,Tbl_SFZ f,zgUser.tbl_S g where a.diqu=b.bianhao and a.KaHao=c.kahao and a.CheckInNo=d.bianhao and left(a.zhengjian,6)=f.SFZBianHao and a.piaolei=e.bianhao and a.ZhengJian=g.ZhengJian and mingma>='18001' and mingma<='18205' order by a.ZhengJian


首先说下这条语句是朋友帮我写的,我的学艺不精,麻烦各位老师帮忙看下这个语句,之前没加g.Expr1、zgUser.tbl_S g,a.ZhengJian=g.ZhengJian这三句是能查出数据的,但是加完后就不显示了,不知问题出在哪里,请各位老师帮忙给解决下,谢谢啦!

------解决方案--------------------
不知道 是否报错 如果没有报错~那 g.Expr1 对结果没有影响,问题出在a.ZhengJian=g.ZhengJian 这个筛选条件上。