注册 登录
编程论坛 ASP技术论坛

重复输出ASP问题!

mianfeixia 发布于 2012-12-20 13:42, 474 次点击

我这里指定了字段,把ID排除了,输出后主题不重复了,但是点击快捷后,因为ID未获取,所有链接都失效了。但是加入ID后,数据又重复了,怎么办?

加入ID后,就变成这样了
有没有解决办法
   
程序代码:
<%
        
set rs=server.createobject("adodb.recordset")      
        rs.open
"select distinct name,shangying,dy,zy,pic,ls,id from mswh3 order by shangying Desc ",conn,1,1
        
if rs.recordcount=0 then
        
%>
        <%
        
else
              rs.PageSize
=6
            iCount
=rs.RecordCount
            iPageSize
=rs.PageSize
            maxpage
=rs.PageCount
            page
=request("page")
   
if Not IsNumeric(page) or page="" then
        page
=1
   
else
        page
=cint(page)
   
end if
   
if page<1 then
        page
=1
   
elseif  page>maxpage then
        page
=maxpage
   
end if
    rs.AbsolutePage
=Page
   
if page=maxpage then
        x
=iCount-(maxpage-1)*iPageSize
   
else
        x
=iPageSize
   
end if
response.Write
"<title>所有电影</title><br/>"
response.Write
"<table border='1' bordercolor='#490000' width='770'><tr>"
            
For i=1 To x
%>


[ 本帖最后由 mianfeixia 于 2012-12-20 13:50 编辑 ]
4 回复
#2
mianfeixia2012-12-20 13:47
字段:name,shangying,dy,zy,pic,ls,id
select distinct  去掉ID后,主题数据不重复,加入ID后,所有数据都输出了。会有很多重复数据!如何让其不重复!!!
#3
ysf01812012-12-20 14:04
distinct,使用这个来查询速度慢的,用列出来结合ASP的判断来查询。
a = ""
b = ""
rs.open"select * from 表 oder by 标题 desc",conn,1,1
do while not rs.eof
   a = 标题
   if b <> a then
      b = a
      response.write b
   end if
rs.movenext
loop
rs.close

其他你自己想了,已提示了。
#4
mianfeixia2012-12-20 14:10
回复 3楼 ysf0181
谢谢!
#5
mianfeixia2012-12-20 14:42
换个思路,已经搞定  :select * from mswh3 a where not exists(select * from mswh3 where name = a.name and id < a.id)
1