如何连接判断字符新方法,如: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
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
相关文章推荐
- 数据库连接,有时会出错在conn.open connstr这地方的问题,及联接查询调用rs("user.id")的问题2006-6-8-4
- MySQL查询优化:LIMIT 1避免全表扫描【如判断用户是否存在select * from users where username='123' and passwd='123' limit 1】
- Apache 选择"only for the Current User, on 8080, when started Manually"时的服务启动方法及如何修改端口号
- 【已解决】SQL30082N Security processing failed with reason "24" ("USERNAME AND/OR PASSWORD INVALID").
- 【Linux】psql: FATAL: Ident authentication failed for user "username" Error and Solution
- spring mongodb Criteria中"and"与"andOperator"方法的区别及"$and"如何工作
- Jquery判断$("#id")获取的对象是否存在的方法
- J2EE Struts2关于"There is no Action mapped for namespace / and action name UserAction"的调试
- 有多少行? SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name') AND indid < 2
- Jquery判断$("#id")获取的对象是否存在的方法
- ibatIS的<dynamic prepend="WHERE">原理,是判断前一个AND字母是否存在
- document.getElementById("idName")用js方法获取元素,则设定风格属性的方法为
- 【转】从判断Session["UserName"].ToString()为null和""所想到的
- java判断request.getParameter("Id")为合法数字,而不包含其他除过数字的字符
- Jquery如何判断 $("#id")获取的对象是否存在
- 关于ViewState的问题 <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="之后有一大串乱码
- 关于ViewState的问题 <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="之后有一大串乱码
- <input type="text" name="" id=""/>中name和id的区别
- 解决"链接服务器 '(null)' 的 OLE DB 访问接口 'STREAM' 返回了对列 '[!BulkInsert].fieldname' 无效的数据"的一种替换方法
- PHP oci8连接oracle数据库出现"ORA-24408: could not generate unique server group name"的解决办法