asp数据显示

gwb12345678 2009-07-28 01:03:42
数据库表
id type
1 1
2 1
3 1
4 1
5 1
6 2
7 2
8 2
9 2
10 3
11 3
12 3
13 3
asp读取后显示成
1 1
6 2
10 3
2 1
7 2
11 3
3 1
8 2
12 3
4 1
9 2
13 3
如何实现?
...全文
46 点赞 收藏 9
写回复
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
anbs01 2009-07-28
if i=1 then
one=""
two=""
three=""
end if
刚才加这个没有用,中间这几句可以去掉了。
回复
anbs01 2009-07-28

set rs1=server.createobject("adodb.recordset")
set rs2=server.createobject("adodb.recordset")
set rs3=server.createobject("adodb.recordset")
sql1="select top 1* from 表 where type=1 order by id"
sql2="select top 1* from 表 where type=2 order by id"
sql3="select top 1* from 表 where type=3 order by id"
rs1.open sql1,conn,1,1
rs2.open sql2,conn,1,1
rs3.open sql3,conn,1,1

for i=0 to rs1.recordcount
i=i+1
response.write(rs1("id")&" "&rs2("type"))
response.write(rs2("id")&" "&rs2("type"))
response.write(rs3("id")&" "&rs3("type"))
if i=1 then
one=""
two=""
three=""
end if
one=one&"and id<>"&rs1("id")
two=two&"and id<>"&rs2("id")
three=three&"and id<>"&rs3("id")
set rs11=server.createobject("adodb.recordset")
set rs22=server.createobject("adodb.recordset")
set rs33=server.createobject("adodb.recordset")
sql11="select top 1 * from 表 where type=1"&one&" order by id"
sql22="select top 1 * from 表 where type=2"&two&" order by id"
sql33="select top 1 * from 表 where type=3"&three&" order by id"
rs11.open sql11,conn,1,1
rs22.open sql22,conn,1,1
rs33.open sql33,conn,1,1
response.write(rs1("id")&" "&rs2("type"))
response.write(rs2("id")&" "&rs2("type"))
response.write(rs3("id")&" "&rs3("type"))
rs11.close
rs22.close
rs33.close
set rs11=nothing
set rs22=nothing
set rs33=nothing
next
rs1.close
rs2.close
rs3.close
set rs1=nothing
set rs2=nothing
set rs3=nothing
回复
gwb12345678 2009-07-28
都不行!谁有办法?
回复
liuwei_IT_love 2009-07-28
str=select * from 数据表名 where type order by type desc
set rs=server.createobject("adodb.recordset")
rs.open str,db,1
if not rs.bof and not rs.eof then
<table>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("type")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
end if
回复
type最好[type]这样
回复

select top 3 * from [表] where type in(select type from[表] group by type) order by type

没有测试,试试看好用不
回复
plcc123 2009-07-28
学习!!
回复
gwb12345678 2009-07-28
怎么读呢?给个详细的代码
回复
Atai-Lu 2009-07-28
有些麻烦,最简单的办法就是分别读取三次,然后一起循环...
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告