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

ACCESS分组查询问题求助

lange2741 发布于 2008-03-25 12:21, 1133 次点击
有一个表NEWS结构如下

字段  aa     vv   
      1      1
      1      2
      1      3
      1      4
      2      1
      2      2
      2      3
      2      4
      3      1
      3      2
      3      3
      3      4
要实现这样的效果
       1    1
            2
            3
            4
       2    1
            2
            3
            4
       3    1
            2
            3  
            4

如何实现这个循环查寻哦??
1 回复
#2
madpbpl2008-03-25 20:34
用两个循环来写吧,试试这样
<%
set rs =Server.CreateObject("adodb.recordset")
sql ="select * from [tb]"
rs.open sql,conn,1,1
if not (rs.eof and rs.bof) then
%>
<Table>
<Tr>
<%
do while not rs.eof
%>
<td><%=rs("aa")%><td>
<td>
<%
set rs1 =Server.CreateObject("adodb.recordset")
sql1 ="select * from [tb] where vv='" & rs("vv") &"'"
rs1.open sql1,conn,1,1
if not (rs1.eof and rs1.bof) then
do while not rs1.eof
%>
<%=rs1("vv")%><BR>
<%
rs1.movenext
loop
rs1.close
set rs1=nothin
end if
%>
</td>
<%
rs.movenext
loop
rs.close
set rs=nothing
end if
%>
</tr>
</table>
1