set rs=server.CreateObject("adodb.recordset")
sql = "select  ExamID from Exam_chapter_Test where chapterID="&chapterId&" "
rs.open sql,Conn,1,3
do while not rs.eof
count = Conn.execute("select count(*) from Exam_chapter_Test where ExamID="&rs(0)&" and chapterID<>"&chapterId&"")(0)
if count=0 then
Conn.execute("update Examda_News set DCourseID=0 where ExamID="&rs(0)&"")
end if
rs.movenext
loop
rs.close
set rs = nothing

解决方案 »

  1.   

    发错地方鸟
    不过你中间的do while里面的,可以全长 if exits来合并
      

  2.   

    两个select 一个UPDATE是不能整合在一起的吧。
      

  3.   

    三条sql没什么共同点
      

  4.   

    <%            set rs=server.CreateObject("adodb.recordset")
                sql = "select  ExamID from Exam_chapter_Test where chapterID="&chapterId&" "
                rs.open sql,Conn,1,3
                do while not rs.eof
                        Conn.execute("update Examda_News set DCourseID=0 where ExamID="& rs(0) &" and (select count(*) from Exam_chapter_Test where ExamID="&rs(0)&" and chapterID<>"&chapterId&")>0")
                    rs.movenext
                loop
                rs.close
                set rs = nothing%>
      

  5.   


    已经接近一步了,怎么能把剩下2条也合成一条呢
    我试过用update from 来写,但是没写对
      

  6.   

    VB这么写,如果第一个SQL语句得到的结果集数据多,会非常慢。