select Employee_Department.Department_ID,Employee_Branch.Branch_ID,Employee_Branch.Branch_Name,Employee_Department.Department_Name from Employee_Department,Employee_Branch where Employee_Department.Branch_ID=Employee_Branch.Branch_ID and Employee_Branch.Branch_ID <>5 and Employee_Branch.Branch_ID <>2 order by Employee_Branch.Branch_ID,Employee_Department.Department_ID
这个sql语句,你在查询分析器里执行一下试试。
代码如下:
<%set rs=server.CreateObject("adodb.recordset")
rs.open "select Employee_Department.Department_ID,Employee_Branch.Branch_ID,Employee_Branch.Branch_Name,Employee_Department.Department_Name from Employee_Department,Employee_Branch where Employee_Department.Branch_ID=Employee_Branch.Branch_ID and Employee_Branch.Branch_ID<>5 and Employee_Branch.Branch_ID<>2 order by Employee_Branch.Branch_ID,Employee_Department.Department_ID",conn,1,1
do while not rs.eof
if len(trim(rs("Department_Name")))=0 then%><optgroup label="<%=rs("Branch_Name")%>"></optgroup><%else%>
<option value="<%=rs("Branch_Name")%>--><%=rs("Department_Name")%>"<%if rs("Department_ID")=session("department_id") then%> selected="selected"<%end if%>><%=rs("Branch_Name")%>--><%=rs("Department_Name")%></option>
temp_id=rs("branch_id")
temp1_id=rs("department_id")
<%end if
rs.movenext
loop%>
<option value="柳志祥">柳志祥</option>
<option value="夏建平">夏建平</option>