上海保洁钟点工:字段中具体显示几条记录代码怎么编写!

来源:百度文库 编辑:中科新闻网 时间:2024/05/02 19:01:35
比如表A中一个字段B中分别有老师、男生、女生。我要显示老师的有几条记录,男生的有几条记录,女生的有几条记录,代码怎么编写!?请高手帮忙,谢谢!
请具体帮我写一下代码啊,谢谢,急用:)

<%
set oRs=Server.CreateObject("adodb.recordset")
sSql="select id from table_name where b="&"老师"
oRs.open sSql,oConn,1,1
if not oRs.eof then
response.write "<font color=red>"&oRs.recordCount&"</font>"
else
response.write "暂时没有老师数据!"
end if
oRs.close
%>
其它的与这个类似,不知你能不能用上。

方法很多,用条件语句举例:
DO WHILE NOT RS.EOF
IF 字段B="老师" THEN
A1=A1+1
ELSEIF 字段B="男生" THEN
A2=A2+1
ELSEIF 字段B="女生" THEN
A3=A3+1
END IF
RS.MOVENEXT
LOOP

aa=conn.execute("select count(*) from [A] where b='老师'")

bb=conn.execute("select count(*) from [A] where b='男生'")

cc=conn.execute("select count(*) from [A] where b='女生'")

先定义一个变量,变量=dcount(*,表A,字段B=“老师”),男生,女生算法一样