多表查询问题
select distinct stinfo.num,stinfo.bj as 班级, stinfo.xm as 姓名,
(select count(*) from stu_zs where stu_zs.num=stinfo.num and stu_zs.state='已拿证') as A,
(select count(*) from stu_zs where stu_zs.num=stinfo.num and stu_zs.state='已报未考') as B,
(select count(*) from stu_zs where stu_zs.num=stinfo.num and stu_zs.state='已考未拿证') as C ,
stinfo.byz_mk
from stu_zs ,stinfo
where stinfo.bj like :bj and stinfo.xm like :xm
以上CODE是DataWindow的Data Source 当执行查询时出现以下错误,
“列前缀'stinfo'与查询中手忙脚乱的表名或别名不匹配”
当where 只用stinfo.bj like:bj 或stinfo.xm like :xm 时没有错误,两个都写的时候就出现以上的错误。请问是什么原因?
如何解决?
[解决办法]
select distinct stinfo.num,stinfo.bj as 班级, stinfo.xm as 姓名, (select count(*) from stu_zs where num=stinfo.num and state='已拿证') as A, (select count(*) from stu_zs where num=stinfo.num and state='已报未考') as B, (select count(*) from stu_zs where num=stinfo.num and state='已考未拿证') as C , stinfo.byz_mk from stinfo where stinfo.bj like :bj and stinfo.xm like :xm