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
不过你中间的do while里面的,可以全长 if exits来合并
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%>
已经接近一步了,怎么能把剩下2条也合成一条呢
我试过用update from 来写,但是没写对