ASP组合查询,拼接字段

'***********Start************
'**************读取变量*************
.
.
.
seaLastUpdTime=Request("seaLastUpdTime1")&"-"&Request("seaLastUpdTime2")&"-"&Request("seaLastUpdTime3")

returnItem=Request("ReturnItem")'******个人设定要返回的字段

'Response.WritereturnItem

'***********拼接字符串***************************

IfreturnItem<>""Then

SQL="SelectComID,ComName,"&returnItem&"FromClientInfoWhereISInva=0"

Else

SQL="SelectComID,ComNameFromClientInfowhereIsInva=0"

EndIf

IfseaComName<>""Then

SQL=SQL&"AndComNameLike'%"&seaComName&"%'"

EndIf

Ifseanexus1<>""Then

SQL=SQL&"Andnexuslike'%"&seanexus1&"%'"

EndIf

Ifseanexus2<>""Then

SQL=SQL&"Andnexuslike'%"&seanexus2&"%'"

EndIf

IfseaComType<>""Then

SQL=SQL&"AndComType='"&seaComType&"'"

EndIf

IfseaComProv<>""Then

SQL=SQL&"AndComProv='"&seaComProv&"'"

EndIf

IfseaTimeFrist11<>""Then

seaTimeFrist1=seaTimeFrist11&"-"&seaTimeFrist12&"-"&seaTimeFrist13

SQL=SQL&"AndTimeFrist>'"&seaTimeFrist1&"'"

EndIf

IfRequest(seaTimeFrist1)<>""Then

seaTimeFrist1=Request(seaTimeFrist1)

SQL=SQL&"AndTimeFrist>'"&seaTimeFrist1&"'"

EndIf

IfseaTimeFrist21<>""Then

seaTimeFrist2=seaTimeFrist21&"-"&seaTimeFrist22&"-"&seaTimeFrist23

SQL=SQL&"AndTimeFrist<'"&seaTimeFrist2&"'"

EndIf

IfRequest(seaTimeFrist2)<>""Then

seaTimeFrist2=Request(seaTimeFrist2)

SQL=SQL&"AndTimeFrist<'"&seaTimeFrist2&"'"

EndIf

IfseaNearTime11<>""Then

seaNearTime1=seaNearTime11&"-"&seaNearTime12&"-"&seaNearTime13

SQL=SQL&"AndTimeNear>'"&seaNearTime1&"'"

EndIf

IfRequest(seaNearTime1)<>""Then

seaNearTime1=Request(seaNearTime1)

SQL=SQL&"AndTimeNear>'"&seaNearTime1&"'"

EndIf

IfseaNearTime21<>""Then

seaNearTime2=seaNearTime21&"-"&seaNearTime22&"-"&seaNearTime23

SQL=SQL&"AndTimeNear<'"&seaNearTime2&"'"

EndIf

IfRequest(seaNearTime2)<>""Then

seaNearTime2=Request(seaNearTime2)

SQL=SQL&"AndTimeNear<'"&seaNearTime2&"'"

EndIf

IfseaAppTime11<>""Then

seaAppTime1=seaAppTime11&"-"&seaAppTime12&"-"&seaAppTime13

SQL=SQL&"AndAppTime>'"&seaAppTime1&"'"

EndIf

IfRequest(seaAppTime1)<>""Then

seaAppTime1=Request(seaAppTime1)

SQL=SQL&"AndAppTime>'"&seaAppTime1&"'"

EndIf

IfseaAppTime21<>""Then

seaAppTime2=seaAppTime21&"-"&seaAppTime22&"-"&seaAppTime23

SQL=SQL&"AndAppTime<'"&seaAppTime2&"'"

EndIf

IfRequest(seaAppTime2)<>""Then

seaAppTime2=Request(seaAppTime2)

SQL=SQL&"AndAppTime<'"&seaAppTime2&"'"

EndIf

IfRequest("seaLastUpdTime1")<>""Then

//seaLastUpdTime0=seaLastUpdTime1&"-"&seaLastUpdTime2&"-"&seaLastUpdTime3

SQL=SQL&"AndLastUpdTime>'"&seaLastUpdTime&"'"

EndIf

IfRequest(seaLastUpdTime1)<>""Then

//seaLastUpdTime0=Request(seaLastUpdTime0)

SQL=SQL&"AndLastUpdTime>'"&seaLastUpdTime&"'"

EndIf

IfSession("Pop")="1"Then

AdminName=Session("UserName")

SQL=SQL&"And(OurSalesLike'%"&AdminName&"%'OrnexusLike'%w%')OrderBy"&Order

Else

Response.WriteSQL

SQL=SQL&"OrderBy"&Order'Order
EndIf

'Response.WriteSQL

你可能感兴趣的:(sql,asp)