Home > front end >  Asp access two tables should satisfy the conditions in the first table to perform the operation of t
Asp access two tables should satisfy the conditions in the first table to perform the operation of t

Time:12-04

Asp + access environment, with two tables in a database, table 1 and table 2, only one row in the table 1 and table 2 N rows, this statement is to conform to the conditions in table 2 of multiple records its field verity value automatically into 1, but now is to add a premise condition is: if the auto fields in table 1=1 to perform the following statement, I do not know how to add the code in front of this statement, please the great god glad

Set the rs=Server. CreateObject (" ADODB. You ")
StrSql="select top 100 id from table 2 where verity=0 and Clicks> Zero order by on desc
"Rs. The open StrSql, Conn, 1, 1
If not rs. Eof and not rs. Bof then
If the rs (" on ") & gt; 1 then
Set verity szupdate="update table 2=1 where id=" & amp; Rs (" id ") & amp;" "
End the if
Conn. Execute szupdate
End the if
Response. Write "the update is successful!"
End the if
Rs. Close
Set the rs=nothing

CodePudding user response:

 if conn. Execute (" Select [auto] From [1] ") (0)=1 then 
Conn. Execute (" update table 2 set verity=1 where verity=0 and Clicks> 1 and id="& amp; Rs (" id "))
End the if

CodePudding user response:

reference 1st floor qq_63572063 response:
 if conn. Execute (" Select [auto] From [1] ") (0)=1 then 
Conn. Execute (" update table 2 set verity=1 where verity=0 and Clicks> 1 and id="& amp; Rs (" id "))
End the if

Excuse me the code to add in what position

CodePudding user response:

 set the rs=Server. CreateObject (" AdoR. You ") 
Rs. Open the "select top Anderson, 1 d, a.C licks, b.a uto from t2, t1 b where Dr. Erity=0 and a.C licks> Zero order by a.C licks desc ", conn, 1, 1
If (not rs. EOF and rs (" on ") & gt; 1 and the rs (" auto ")=1) then
Conn. Execute (" update table 2 set verity=1 where id="& amp; Rs (" id "))
Response. Write "the update is successful!"
End the if
Rs. Close

CodePudding user response:

reference 1st floor qq_63572063 response:
 if conn. Execute (" Select [auto] From [1] ") (0)=1 then 
Conn. Execute (" update table 2 set verity=1 where verity=0 and Clicks> 1 and id="& amp; Rs (" id "))
End the if
replace you above the entire line,

CodePudding user response:

reference 4 floor qq_63572063 response:
Quote: reference 1st floor qq_63572063 response:
 if conn. Execute (" Select [auto] From [1] ") (0)=1 then 
Conn. Execute (" update table 2 set verity=1 where verity=0 and Clicks> 1 and id="& amp; Rs (" id "))
End the if
replace you above the entire line,


Mean you gave me above these three lines of the whole line 13 will replace it?

CodePudding user response:

 
Set the rs=Server. CreateObject (" ADODB. You ")
Rs. Open the "select top 1 [auto] from [1]", Conn, 1, 1
If the rs. Fields (0)=1 then
Conn. Execute the update "[2] set verity=1 where verity=0 and Clicks>
0"End the if
  •  Tags:  
  • ASP
  • Related