日期:2014-05-17  浏览次数:20938 次

求一sql复杂语句
<!--   -->
  <%
    set   rs1=server.createobject( "adodb.recordset ")
    sql= "SELECT   *   FROM   sort   where   fatherID= "&request( "id ")& " "
    rs1.open   sql,conn,1,3
    do   while   not   rs1.eof
  %>
        <%set   rs2=server.createobject( "adodb.recordset ")
            sql= "SELECT   *   FROM   sjzq   where   productSort= "&rs1( "id ")& "   and
            recommend=1   and   userid   in   (select   id   from   register   where  
            leixing= 'aa ')   order   by   id   desc "
            rs2.open   sql,conn,1,3
            do   while   not   rs2.eof
        %>
      <tr>
                        <td> 名称: <%=rs2( "title ")%> </td>
                      </tr>
        <%rs2.movenext
            loop
            rs2.close
            set   rs2=nothing
        %>
  <%rs1.movenext
    loop
    rs1.close
    set   rs1=nothing
  %>
<!--   -->
  <%
    set   rs1=server.createobject( "adodb.recordset ")
    sql= "SELECT   *   FROM   sort   where   fatherID= "&request( "id ")& " "
    rs1.open   sql,conn,1,3
    do   while   not   rs1.eof
  %>
        <%set   rs2=server.createobject( "adodb.recordset ")
            sql= "SELECT   *   FROM   sjzq   where   productSort= "&rs1( "id ")& "   and
            recommend=1   and   userid   in   (select   id   from   register   where  
            leixing= 'bb ')   order   by   id   desc "
            rs2.open   sql,conn,1,3
            do   while   not   rs2.eof
        %>
      <tr>
                        <td> 名称: <%=rs2( "title ")%> </td>
                      </tr>
        <%rs2.movenext
            loop
            rs2.close
            set   rs2=nothing
        %>
&