如何将多条记录存入一个字段中
现在我有两个表,一个存入用户信息表,一个表存放用户相关活动情况表,要将用户表中的姓名多次将取出放直用户活动情况表中的一个字段下面
set rs_l = server.createobject("adodb.recordset")
sql_l = "select * from "& db_leave_Table &" where id is null" '用户活动情况表
rs_l.Open sql_l,conn,1,3
rs_l.addnew
rs_l("title") = title
rs_l("depid") = depid
rs_l("deptype") = depname
rs_l("username") = username
rs_l("qjsj_start") = qjstart
rs_l("qjsj_end") = qjend
rs_l("updatetime") = now()
rs_l("qjflag") = 0
rs_l("firstflag") = 0
rs_l("comment") = comment
rs_l.update
lid = rs_l("id")
set rs = server.createobject("adodb.recordset")
sqlstr = "select * from "& db_user_Table &" where userlevel<2" '用户信息表
rs.Open sqlstr,conn,1,1
dim arr()
redim arr(rs.recordcount)
for m = 1 to rs.recordcount
arr(m) = rs("username")
strClass = rs("userclass")
arrClass = split(strClass,",")
arrClass1 = UBound(arrClass)
for i=0 to arrClass1
if cint(arrClass(i)) = cint(depid) then 'depid为自定义的cookies
set rs2 = server.createobject("adodb.recordset")
sqlstr = "select * from "& db_leave_Table &" where id="&lid
rs2.Open sqlstr,conn,1,3
rs2("userclass") = arr(m) '将用户名存入userclass中,每次都会覆盖上一次的用户名,能不能不覆盖用","隔开
rs2.Update
end if
next
rs.movenext
next
rs.close
------解决方案--------------------
楼主数据表建的有问题,应该用用户表的ID,不应该用姓名
------解决方案--------------------
rs2("userclass") = rs2("userclass") & "," & arr(m)
-------
不过还是应该从表的设计解决问题