asp如何同时查询记录并将记录插入另外表中?
我的代码是keys_news=""keys_news=keys_news&"<tablewidth=90%border=0align=centercellpadding=...
我的代码是
keys_news=""
keys_news=keys_news&"<table width=90% border=0 align=center cellpadding=0 cellspacing=0>"
set rs1=server.createobject("adodb.recordset")
'sql="SELECT TOP 10 * FROM otlinks ORDER BY rnd(id)"
sql="Select top 1 * FROM [otlinks] orDER BY Rnd(id)"
rs1.open sql,conn,1,1
do while not (rs1.eof or err)
keys_news=keys_news&"<tr>"
keys_news=keys_news&"<td
class=center01>·<a
href="&rs1("otlinks")&">"&rs1("keywords")&"</a></td>"
keys_news=keys_news&"</tr>"
rs1.movenext
loop
keys_news=keys_news&"</table>"
现在我想在sql="SELECT TOP 1 * FROM otlinks ORDER BY rnd(id)"查询出的两个记录后再插入到另外一张info表中。求各路高手帮忙!谢谢 展开
keys_news=""
keys_news=keys_news&"<table width=90% border=0 align=center cellpadding=0 cellspacing=0>"
set rs1=server.createobject("adodb.recordset")
'sql="SELECT TOP 10 * FROM otlinks ORDER BY rnd(id)"
sql="Select top 1 * FROM [otlinks] orDER BY Rnd(id)"
rs1.open sql,conn,1,1
do while not (rs1.eof or err)
keys_news=keys_news&"<tr>"
keys_news=keys_news&"<td
class=center01>·<a
href="&rs1("otlinks")&">"&rs1("keywords")&"</a></td>"
keys_news=keys_news&"</tr>"
rs1.movenext
loop
keys_news=keys_news&"</table>"
现在我想在sql="SELECT TOP 1 * FROM otlinks ORDER BY rnd(id)"查询出的两个记录后再插入到另外一张info表中。求各路高手帮忙!谢谢 展开
1个回答
展开全部
这个sql加了top 1只能随机查询出一个,查询出两个记录后是什么意思,说明白点
更多追问追答
追问
查询出记录后再更新到另外一张表中。
追答
sql = "SELECT top 1 vale1, value2 into info from otlinks order by rnd(id)"
或
sql = "Insert into info(field1,field2) select top 1 value1,value2 from otlinks order by rnd(id)"
conn.execute(sql)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询