如何连接判断字符新方法,如:where id0 and username="" and ......2006-6-8-3

来源:互联网 发布:淘宝网怎么改密码找回 编辑:程序博客网 时间:2024/05/16 05:02

sql="select * from tables  where id<>0 "
if uid<>"" then sql=sql&" and uid=1 "
if uid2<>"" then sql=sql&" and uid2=1 "
if uid3<>"" then sql=sql&" and uid3=1 "

上边的连接是大家常用到的,下边是针对排序的.

if uid="1" then ostr=ostr&" ,uid desc "
if uid="2" then ostr=ostr&" ,uid  "
if uid2="1" then ostr=ostr&" ,uid2 desc "
if uid2="2" then ostr=ostr&" ,uid2  "
if uid3="1" then ostr=ostr&" ,uid3 desc "
if uid3="2" then ostr=ostr&" ,uid 3 "
ostr=mid(ostr,1)            '这一步的作用是,以前的取排序操作字段的时候没有考虑:这个字段前边是不是已经有一个了,现在不用考虑,直接写到最后把前边的那个", "用mid去掉就行
if len(trim(ostr))<>0 then
  sql=sql&" order by "&ostr
  end if

原创粉丝点击