查询优化代码(分别查询前几条,之后的几条,再后面的几条)
庄子 2009-05-16 10:37:30 我要分别查询前4条, 4-8条, 8-12条, 12-16,16-20
我用的是下面的查询过程, 但是这个在我网页里, 当出现过两次以后, 查询速度就会一下子变的奇慢无比, 有谁能帮我优化下吗
<%call Qylist(4,"""",15)%>,<%call Qylist(4,4,15)%>,<%call Qylist(4,8,15)%>,
<%
'*************************************************
'函数名:qylist 企业黄页列表(首页)
'作 用:显示企业列表
'参 数:
' top ------显示行数
' strlen ----截取长度
'返回值:截取后的字符串
'*************************************************
sub qylist(top,pretop,strlen)
sql="select top "&top&" ID,Qymc,url from Corporation where cFlag=1 and Uflag =1 and huangye =1"
if pretop <> """" then
sql=sql&" and ID not in (select top "&pretop&" ID from Corporation where cFlag=1 and Uflag =1 and huangye =1 order by ID desc)"
end if
sql = sql &" order by ID desc"
' response.Write(sql)
rs.open sql,conn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
id =rs("ID")
qytitle = rs("Qymc")
url = rs("url")
%>
<li><% if IsNull(url)=False then%><a href="/<%=url%>" target="_blank"><%else%><a href="/company/1/index.asp?GsID=<%=id%>" target="_blank"><%end if%><%=gotTopic(qytitle,strlen)%></a></li>
<%
rs.movenext
loop
end if
rs.close
end sub
%>