SQL语句中用join和count、where的问题

sqlstr="select count("&ksgkrs("kscj")&".xsbh) from "&ksgkrs("kscj")&" INNER JOIN stu_s on "&ksgkrs("kscj")&".xsbh=stu_s.stu_bh where isnull("&ksgkrs("kscj")&".cj"&kskms(j)&") and stu_s.nj="&nianjis(i)
这个语句总是报错:
错误类型:
Microsoft JET Database Engine (0x80040E10)
至少一个参数没有被指定值。

用response.write打印出来是:
select count(20090416cj.xsbh) from 20090416cj INNER JOIN stu_s on 20090416cj.xsbh=stu_s.stu_bh where isnull(20090416cj.cj1) and stu_s.nj=2008

试过把表名加上[和]:
select count([20090416cj].xsbh) from [20090416cj] INNER JOIN [stu_s] on [20090416cj].xsbh=[stu_s].stu_bh where isnull([20090416cj].cj1) and [stu_s].nj=2008
也一样出错。

我的意图是想结合两个表(20090416cj和stu_s)统计年级为2008的cj1的值为空的人数,因为stu_s中有学生年级stu_s.nj,而20090416cj中没有,所以必须两个表结合起来查。

[20090416cj].xsbh 和 stu_s.stu_bh 分别是两个表中的学生编号,是自动编号,都有内容且具有唯一性。

请教是什么问题?
已经解决了,谢谢耐心解答!

判断字段是否为空不能用isnull
应该用is null
试下下面的sql
select count([20090416cj].xsbh) from [20090416cj] INNER JOIN [stu_s] on [20090416cj].xsbh=[stu_s].stu_bh where ([20090416cj].cj1) is null and [stu_s].nj=2008
温馨提示:答案为网友推荐,仅供参考
相似回答