首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

多表查询有关问题

2012-04-07 
多表查询问题select distinct stinfo.num,stinfo.bj as 班级, stinfo.xm as 姓名,(select count(*) from s

多表查询问题
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 时没有错误,两个都写的时候就出现以上的错误。请问是什么原因?
如何解决?





[解决办法]

SQL code
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 

热点排行