sql="select * from table where"
if 条件1<>"" then sql=sql&" and ziduan1='"&条件1&"'"
if 条件2<>"" then sql=sql&" and ziduan2='"&条件2&"'"
if 条件3<>"" then sql=sql&" and ziduan3 like '%"&条件3&"%'"
if 条件4<>"" then sql=sql&" and ziduan4=‘"&条件4“”
.
. '类推增加条件
.
if 条件n<>"" then sql=sql&" and ziduann='"&条件n&"'"
sql=replace(sql,"where and","where")
if right(sql,5)="where" then sql=left(sql,clng(len(sql))-5) '最後加order by id descsql= sql & " order by id desc "
if 条件1<>"" then sql=sql&" and ziduan1='"&条件1&"'"
if 条件2<>"" then sql=sql&" and ziduan2='"&条件2&"'"
if 条件3<>"" then sql=sql&" and ziduan3 like '%"&条件3&"%'"
if 条件4<>"" then sql=sql&" and ziduan4=‘"&条件4“”
.
. '类推增加条件
.
if 条件n<>"" then sql=sql&" and ziduann='"&条件n&"'"
sql=replace(sql,"where and","where")
if right(sql,5)="where" then sql=left(sql,clng(len(sql))-5) '最後加order by id descsql= sql & " order by id desc "
這樣可以把下面2句去掉了
//sql=replace(sql,"where and","where")
//if right(sql,5)="where" then sql=left(sql,clng(len(sql))-5) 排序不防也弄個字段傳進去,這樣比較清楚
if 条件1<>"" then sql=sql&" and ziduan1='"&条件1&"'"
if 条件2<>"" then sql=sql&" and ziduan2='"&条件2&"'"
if 条件3<>"" then sql=sql&" and ziduan3 like '%"&条件3&"%'"
if 条件4<>"" then sql=sql&" and ziduan4=‘"&条件4“”
sql=sql&" order by id desc"
playwarcraft(时间就像乳沟,挤挤还是有的)
wgzaaa() 分都给结了!
下次再补,好了!