高手们,新年快乐!
数据库:temrenwu
id zhixing renwu finish
1 aa|| ........... 2
2 aa|bb .......... 2
3 bb|cc
4 |bb|
5 |bb|cc
zhixing 列为 "执行人 "...
cookieusername 变量为 当前用户
请问有什么办法将下面的SQL查询语句改一下,变成数据库只查询出当前用户为执行人的数据.
例如,当前用户是aa ,那么如果查询出:ID1和ID2呢?
sqltext1= "Select * From temrenwu where and finish= '2 ' Order By id Desc "
我自己的方法是:
<% if instr( "| "&zhixing& "| ", "| "&CookieUserName& "| ")> 0 then %>
显示记录
<%else%> <%end if%>
这个方法,如果数据多时,不好用,能不能直接就在SQL查询语句里面改啊??
谢谢大家!!
------解决方案--------------------
sqltext1= "Select * From temrenwu where and finish= '2 ' and zhixing like '| "&CookieUserName& "| ' "
------解决方案--------------------
shit!写错了
sqltext1= "Select * From temrenwu where and finish= '2 ' and charindex(zhixing, '| "&CookieUserName& "| ')> 0 "
------解决方案--------------------
试试看
sqltext1= "Select * From temrenwu where and finish= '2 ' and zhixing like '% "&CookieUserName& "% ' "