页面已经获取session["username"],现在要找出数据表里某3列字段包含该用户名的记录,如何写呢?
比如:
字段名:id agroup bgroup cgroup
记录: 1 a,b c b,d
2 a b c
假设 session["username"]=d,那么我想取到第一条记录要怎么写呢?
------解决方案--------------------
- SQL code
select top 1 * from tb where charindex(',[email protected]+',' , ','+agroup+',') > 0 or charindex(',[email protected]+',' , ','+bgroup+',') > 0 or charindex(',[email protected]+',' , ','+cgroup+',') > 0
------解决方案--------------------
- SQL code
select top 1 *from tablewhere charindex(',d,',','+agroup+',') > 0 or charindex(',d,',','+bgroup+',') > 0or charindex(',d,',','+cgroup+',') > 0order by id
------解决方案--------------------
[email protected]
因为四楼的写法是变量赋值的
你前面加个
set @session=''d''