欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

组合查询之核心:拼接字符串

程序员文章站 2022-07-02 15:38:27
组合查询之核心:拼接字符串功能:定义查询条件,定义返回集,定义排序方式平台:windows 2000 server + iis5.0 + sql server 2000语言:vbscript作者:c...
组合查询之核心:拼接字符串
功能:定义查询条件,定义返回集,定义排序方式
平台:windows 2000 server + iis5.0 + sql server 2000
语言:vbscript
作者:cheery_ke
***********start************
**************读取变量*************
.
.
.
sealastupdtime = request("sealastupdtime1")&"-"&request("sealastupdtime2")&"-"&request("sealastupdtime3")

returnitem = request("returnitem")******个人设定要返回的字段

response.write returnitem

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

if returnitem <> "" then

sql = "select comid,comname, " & returnitem & " from clientinfo where isinva = 0"

else

sql = "select comid,comname from clientinfo where isinva = 0"

end if

if seacomname <> "" then

sql = sql & " and comname like %"&seacomname&"%"

end if

if seanexus1 <> "" then

sql = sql & " and nexus like %"&seanexus1&"%"

end if

if seanexus2 <> "" then

sql = sql & " and nexus like %"&seanexus2&"%"

end if

if seacomtype <> "" then

sql = sql & " and comtype = "&seacomtype&""

end if

if seacomprov <> "" then

sql = sql & " and comprov = "&seacomprov&""

end if

if seatimefrist11 <> "" then

seatimefrist1 = seatimefrist11&"-"&seatimefrist12&"-"&seatimefrist13

sql = sql & " and timefrist > "&seatimefrist1&""

end if

if request(seatimefrist1) <> "" then

seatimefrist1 = request(seatimefrist1)

sql = sql & " and timefrist > "&seatimefrist1&""

end if

if seatimefrist21 <> "" then

seatimefrist2 = seatimefrist21&"-"&seatimefrist22&"-"&seatimefrist23

sql = sql & " and timefrist < "&seatimefrist2&""

end if

if request(seatimefrist2) <> "" then

seatimefrist2 = request(seatimefrist2)

sql = sql & " and timefrist < "&seatimefrist2&""

end if

if seaneartime11 <> "" then

seaneartime1 = seaneartime11&"-"&seaneartime12&"-"&seaneartime13

sql = sql & " and timenear > "&seaneartime1&""

end if

if request(seaneartime1) <> "" then

seaneartime1 = request(seaneartime1)

sql = sql & " and timenear > "&seaneartime1&""

end if

if seaneartime21 <> "" then

seaneartime2 = seaneartime21&"-"&seaneartime22&"-"&seaneartime23

sql = sql & " and timenear < "&seaneartime2&""

end if

if request(seaneartime2) <> "" then

seaneartime2 = request(seaneartime2)

sql = sql & " and timenear < "&seaneartime2&""

end if

if seaapptime11 <> "" then

seaapptime1 = seaapptime11&"-"&seaapptime12&"-"&seaapptime13

sql = sql & " and apptime > "&seaapptime1&""

end if

if request(seaapptime1) <> "" then

seaapptime1 = request(seaapptime1)

sql = sql & " and apptime > "&seaapptime1&""

end if

if seaapptime21 <> "" then

seaapptime2 = seaapptime21&"-"&seaapptime22&"-"&seaapptime23

sql = sql & " and apptime < "&seaapptime2&""

end if

if request(seaapptime2) <> "" then

seaapptime2 = request(seaapptime2)

sql = sql & " and apptime < "&seaapptime2&""

end if

if request("sealastupdtime1") <> "" then

// sealastupdtime0 = sealastupdtime1&"-"&sealastupdtime2&"-"&sealastupdtime3

sql = sql & " and lastupdtime > "&sealastupdtime&""

end if

if request(sealastupdtime1) <> "" then

//sealastupdtime0 = request(sealastupdtime0)

sql = sql & " and lastupdtime > "&sealastupdtime&""

end if

if session("pop") = "1" then

adminname = session("username")

sql = sql & " and (oursales like %"&adminname&"% or nexus like %w%) order by " & order

else

response.write sql

sql = sql & " order by "& order order设定排序方式

end if

response.write sql

******end***********************