micorsoft ppt2010:我选6条记录,为什么出来了11条???

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/06 01:16:33
<table width=93% align=center><%set rs=server.createobject("adodb.recordset")
rs.open "select Top 6 title,idxu,updatetime from article where idz=16 and deleted=false order by updatetime desc",conn,1,1
if rs.recordcount=0 then%>暂无动态<%
else
while not rs.eof
%><tr><td><font color="#f14f0a">·</font><a href=dongtai.asp?idxu=<%=rs("idxu")%> target=_self><span class=13px><%if len(trim(rs("title")))>20 then
response.write left(trim(rs("title")),20)&"..."
else
response.write trim(rs("title"))
end if%></span></a></td><td class=riqi><%=rs("updatetime")%></td></tr>
<%rs.movenext%><%
wend
end if%><%rs.close
set rs=nothing%></table>
不加这个order by updatetime desc是对的,加了后就多于6条了

因为你的updatetime数据有重复

当排序的字段的结果在表中有重复时将显示所有符合条件的数据。

请在语句后边再加上 有唯一表示的字段
比如 ordey by up_time desc,auto_id desc

你先把你的这个语句
select Top 6 title,idxu,updatetime from article where idz=16 and deleted=false order by updatetime desc
直接在SQL上运行,看看返回结果是否是6条