比如我查询界面上是有以下七项:
需求主旨、需求提出日期,(需求提出日期)至(哪年哪月哪日),希望上线日期,(希望上线日期)至(哪年哪月哪日),资讯主办,需求状态
前面6项都在同一个数据表中REQUIRE_BILL
最后的需求状态在REQUIRE_LOG 表中
但是我显示的查询结果需要显示
需求单位,需求提出人,需求主旨,资讯主办,需求提出日期,希望上线日期,预估完成日期,状态
前面红色的都在表REQUIRE_BILL中,状态在REQUIRE_LOG中
动态显示在表格中的语句应该要怎么写啊?
<!--#include file="conn.asp"-->
<form action="dispose_demand.asp" method="post" name="dispose_demand">
以下为查询的语句:
dim MAJOR_IFEA,APPLY_TIME,APPLY_TIME_END,WISH_FINISH_TIME,WISH_FINISH_TIME_END,IT_UNDERTAKER,ACTMCONT
MAJOR_IDEA=Trim(request.form("MAJOR_IDEA"))
APPLY_TIME=Trim(request.form("APPLY_TIME"))
APPLY_TIME_end=Trim(request.form("APPLY_TIME"))
WISH_FINISH_TIME=Trim(request.form("WISH_FINISH_TIME"))
WISH_FINISH_TIME_end=Trim(request.form("WISH_FINISH_TIME"))
IT_UNDERTAKER=Trim(request.form("IT_UNDERTAKER"))
ACTMCONT=Trim(request.form("ACTMCONT"))
sql="select * from REQUIRE_BILL where 1=1"
if MAJOR_IDEA <>"" then
sql=sql&"and MAJOR_IDEA like '%"& MAJOR_IDEA &"%'"
end if
if APPLY_TIME <>"" and APPLY_TIME_end <>"" then
sql=sql&"select * from REQUIRE_BILL where CONVERT(int,MONTH(date))>=APPLY_TIME and CONVERT(int,MONTH(date))<=APPLY_TIME_end"
end if
if APPLY_TIME<>""and APPLY_TIME_end="" then
sql=sql&"select * from REQUIRE_BILL where CONVERT(int,MONTH(date))>=APPLY_TIME"
end if
if APPLY_TIME="" and APPLY_TIME_end<>"" then
sql=sql&"select * from REQUIRE_BILL where CONVERT(int,MONTH(date))<=APPLY_TIME_end"
end if
if WISH_FINISH_TIME<>"" and WISH_FINISH_TIME_end<>"" then
sql=sql&"select * from REQUIRE_BILL where CONVERT(int,MONTH(date))>=WISH_FINISH_TIME and CONVERT(int,MONTH(date))<=WISH_FINISH_TIME_end"
end if
if WISH_FINISH_TIME<>"" and WISH_FINISH_TIME_end="" then
sql=sql&"select * from REQUIRE_BILL where CONVERT(int,MONTH(date))>=WISH_FINISH_TIME"
end if
if WISH_FINISH_TIME="" and WISH_FINISH_TIME_end<>"" then
sql=sql&"select * from REQUIRE_BILL where CONVERT(int,MONTH(date))<=WISH_FINISH_TIME_end"
end if
if IT_UNDERTAKER <>"" then
sql=sql&"and IT_UNDERTAKER = '"& IT_UNDERTAKER &"'"
end if
sqlstr="select * from REQUIRE_LOG where 1=1"
if ACTMCONT<>"" then
sqlstr=sqlstr&"and ACTMCONT ='"& ACTMCONT &"'"
中间的html省略
以下为显示查询结果的表格
<table cellpadding=1 align="center" cellspacing=1 border=1 width="800" height="1" >
response.write"<tr>"
response.write"<td width=100> 需求单位 </td>"
response.write"<td width=100> 需求提出人 </td>"
response.write"<td width=100> 主旨 </td>"
response.write"<td width=100> 资讯主办 </td>"
response.write"<td width=100> 需求提出日期</td>"
response.write"<td width=100> 希望上线日期 </td>"
response.write"<td width=100> 预估完成日期 </td>"
response.write"<td width=100> 状态</td></tr>"
SQL = "select * from REQUIRE_BILL ,REQUIRE_LOG where REQUIRE_BILL.IT_NO = REQUIRE_LOG.IT_NO "
Rs.open SQL,CONN,1,1
if Not rs.Eof then Rs.MoveFirst
Do while Not rs.Eof
nAPPLY_DEPARTMENT=trim(rs.fields("APPLY_DEPARTMENT"))
nAPPLIER=trim(rs.fields("APPLIER"))
nMAJOR_IDEA=trim(rs.fields("MAJOR_IDEA"))
nIT_UNDERTAKER=trim(rs.fields("IT_UNDERTAKER"))
nAPPLY_TIME=trim(rs.fields("APPLY_TIME"))
nWISH_FINISH_TIME=trim(rs.fields("WISH_FINISH_TIME"))
nTOTESTTIME=trim(rs.fields("TOTESTTIME"))
nACTMCONT=trim(rs.fields("ACTMCONT"))
response.write"<tr>"
response.write"<td width=100>" & nAPPLY_DEPARTMENT & "</td>"
response.write"<td width=100>" & nAPPLIER & "</td>"
response.write"<td width=100>" & nMAJOR_IDEA & "</td>"
response.write"<td width=100>" & nIT_UNDERTAKER & "</td>"
response.write"<td width=100>" & nAPPLY_TIME & "</td>"
response.write"<td width=100>" & nWISH_FINISH_TIME & "</td>"
response.write"<td width=100>" & nTOTESTTIME & "</td>"
response.write"<td width=100>" & nACTMCONT & "</td></tr>"
Rs.MoveNext
Loop
这样能实现所要求的查询效果吗