asp+access環境。資料庫中有兩個表,表1和表2。表1中只有一行記錄,表2中有N行記錄。這段陳述句是將表2中符合條件的多個記錄將其欄位verity的值自動變為1,但現在是要加一個前提條件是:如果表1中欄位auto=1 才執行下面的陳述句。不知怎么添加代碼在這段陳述句的前面,請各位大神不吝賜教。
Set rs = Server.CreateObject("ADODB.RecordSet")
StrSql="select top 100 id from 表2 where verity=0 and Clicks>0 order by Clicks desc"
rs.open StrSql,Conn,1,1
If not rs.eof and not rs.bof then
if rs("Clicks")>1 then
szupdate="update 表2 set verity=1 where id="&rs("id")&""
end if
Conn.execute szupdate
end if
Response.write "更新成功!"
end if
rs.close
set rs=nothing
uj5u.com熱心網友回復:
if conn.execute("Select [auto] From [表1]")(0) = 1 then
conn.execute("update 表2 set verity=1 where verity=0 and Clicks>1 and id="&rs("id"))
end if
uj5u.com熱心網友回復:
請問一下這個代碼加在什么位置呢
uj5u.com熱心網友回復:
set rs = Server.CreateObject("AdoR.RecordSet")
rs.open "select top 1 a.id, a.Clicks, b.auto from t2 a, t1 b where a.verity=0 and a.Clicks>0 order by a.Clicks desc", conn, 1, 1
if(not rs.EOF and rs("Clicks")>1 and rs("auto")=1) then
conn.execute("update 表2 set verity=1 where id=" & rs("id"))
Response.Write "更新成功!"
end if
rs.close
uj5u.com熱心網友回復:
替換你上面的整行。uj5u.com熱心網友回復:
意思你這三行就把我上面的整個13行全部就替換就行了?
uj5u.com熱心網友回復:
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.open "select top 1 [auto] from [表1]",Conn,1,1
if rs.fields(0)=1 then
conn.execute "update [表2] set verity=1 where verity=0 and Clicks>0"
end if
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/20257.html
標籤:ASP
上一篇:已經在本地除錯好的Django專案部署到centos7服務器上發現無法找到靜態檔案圖片、樣式,但是之前在本地除錯程序就沒有毛病。請問怎么部署服務器的靜態檔案。
下一篇:關于css中的清楚浮動
