您的位置:首页 > 其它

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

2006-06-08 10:39 567 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐