id tm
1001 aa
1001 bb
1001 cc
1005 aa
1005 bb
1005 cc
1005 dd
要求查询结果为
id tm
1001 aa,bb,cc
1002 aa,bb,cc,dd
请知道的赐教
<%
set rs=server.createobject("adodb.recordset")
rs.open "select id from table1 order by id Asc",conn,1,1
if not(rs.eof and rs.bof) then
response.write"共<font color=""red"">"&rs.recordcount&"</font>条新"
set rs1=server.createobject("adodb.recordset")
rs1.open "select count(Id),id from table1 group by id",conn,1,1
do while not rs1.eof
set rs2=server.createobject("adodb.recordset")
rs2.open "select id from table1 and UserId='"&rs1("id")&"'",conn,1,1
if rs2.recordcount=1 then B="①"
if rs2.recordcount=2 then B="②"
if rs2.recordcount=3 then B="③"
if rs2.recordcount=4 then B="④"
if rs2.recordcount=5 then B="⑤"
if rs2.recordcount=6 then B="⑥"
if rs2.recordcount=7 then B="⑦"
if rs2.recordcount=8 then B="⑧"
if rs2.recordcount=9 then B="⑨"
if rs2.recordcount=10 then B="⑩"
response.write"[<font color=""green"">"&rs1("Id")&"</font><font color=""red"">"&B&"</font>]"
rs2.close
set rs2=nothing
rs1.movenext
loop
rs1.close
set rs1=nothing
else
response.write"<span disabled>(暂无)</span>"
end if
rs.close
set rs=nothing
%>
[此贴子已经被作者于2007-9-12 8:27:55编辑过]