表teset
字段:
ID PY
1 A
2 B
3 A
4 D
5 C
6 B
7 1
8 A
9 A
10 AHas="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"主要想实现的功能:
用ASP中的Has字符串与表teset中PY字段进行比较,如果字段中存在这个字母,就用A标签显示,如果不存在就直接输出,如果是数字,就输出数字,具体如下:'比如PY字段中有A
Response.Write "<a target=""_self"" href=""#a"">A</a>"
'如果没有A
Response.Write "A"
'如果有数字,则直接输出
Response.Write "1"
解决方案 »
- 谁有大数据量的数据库,可以给我一个吗
- 备份服务器下全部的数据库
- 關於Union查詢。如果每一個查詢都要排序,然後union的時候會出錯,怎麼解決?
- 在多个数据库间建立表的视图,如何创建视图索引?
- 需求分析之后的问题...
- 数据库里数据量增大后,应用程序查询速度变慢
- 如何一条语句更新多个表的记录
- bde如何自动配置而不用手工配置 ,急呀!!!在线等,送高分
- 在sql2000server中_data文件是不是就是数据库文件,_log文件是不是就是日志文件,我发现_log文件很大很大,如何把无用过时的日志删除?
- 高难度的问题!!我认为。
- 高分求一存储过程,关于时间的分段查询问题
- SQL语句创建表格时出问题了,麻烦各位帮忙看看,很急,谢谢啦
create table #tb(ID int,PY char(1))
insert into #tb
select 1,'A'
union all select 2,'B'
union all select 3,'A'
union all select 4,'D'
union all select 5,'C'
union all select 6,'B'
union all select 7,1
union all select 8,'A'
union all select 9,'A'
union all select 10,'A'declare @Has varchar(1000)
set @Has='A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z'
select case when charindex(','+cast(PY as varchar)+',',','+@Has+',')=0 then PY
else '"<a target=""_self"" href=""#a"">'+cast(PY as varchar)+'</a>"' end as result
from #tb
drop table #tb--结果
/*
"<a target=""_self"" href=""#a"">A</a>"
"<a target=""_self"" href=""#a"">B</a>"
"<a target=""_self"" href=""#a"">A</a>"
"<a target=""_self"" href=""#a"">D</a>"
"<a target=""_self"" href=""#a"">C</a>"
"<a target=""_self"" href=""#a"">B</a>"
1
"<a target=""_self"" href=""#a"">A</a>"
"<a target=""_self"" href=""#a"">A</a>"
"<a target=""_self"" href=""#a"">A</a>"
*/
insert into #tb
select 1,'A'
union all select 2,'B'
union all select 3,'A'
union all select 4,'D'
union all select 5,'C'
union all select 6,'B'
union all select 7,1
union all select 8,'A'
union all select 9,'A'
union all select 10,'A'declare @Has varchar(1000)
set @Has='A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z'
select distinct case when charindex(','+cast(PY as varchar)+',',','+@Has+',')=0 then PY
else '"<a target=""_self"" href=""#a"">'+cast(PY as varchar)+'</a>"' end as result
from #tb
drop table #tb--结果
/*
"<a target=""_self"" href=""#a"">A</a>"
"<a target=""_self"" href=""#a"">B</a>"
"<a target=""_self"" href=""#a"">C</a>"
"<a target=""_self"" href=""#a"">D</a>"
1
*/
<a target=""_self"" href=""#a"">B</a>
<a target=""_self"" href=""#a"">C</a>
<a target=""_self"" href=""#a"">D</a>
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
1