我要查出当aid=4时,Product_Attribute包含aid的数据
发布网友
发布时间:2024-10-24 11:19
我来回答
共1个回答
热心网友
时间:2024-11-14 13:21
你得先把Proct_Attribute查出来放到变量里然后再用变量比较,得到id列表,然后再用sql语句查出来.
aid=Trim(Request.QueryString("aid"))
set rsp=server.createobject("adodb.recordset")
sqlp="select id,Proct_Attribute from Proct"
rsp.open sqlp,conn,1,1
idlist=""
while not rsp.eof
arr = split(rs(1),",")
for each p in arr()
if p=aid then idlist =idlist&","&rsp(0)
next
idlist =idlist&","&rsp(0)
rsp.movenext
wend
rsp.close
if len(idlist)=0 then
cond = "where 1=0"
else
idlist = right(len(idlist)-1)
cond = "where id in ("&idlist&") order by Proct_id"
end if
set rsp=server.createobject("adodb.recordset")
sqlp="select * from Proct "&cond
rsp.open sqlp,conn,1,1