我的表中有这么个字段,格式为:A@@B@@C我的要求将这个字段的值变为多条,即:1.A
2.B
3.C
在不用存储过程的情况下,用以条SQL写出来,
现在唯一能确定的是@@是分隔符,其他的都不确定
所以要求要写灵活一点我自己写出一个,不够灵活所以希望看看大家有什么好怕方法没有,谢谢!
2.B
3.C
在不用存储过程的情况下,用以条SQL写出来,
现在唯一能确定的是@@是分隔符,其他的都不确定
所以要求要写灵活一点我自己写出一个,不够灵活所以希望看看大家有什么好怕方法没有,谢谢!
解决方案 »
- maven 创建项目报错,求帮忙!!
- struts2批量添加
- 哪位帮我解决一下关于Hibernate映射的怪现象
- 高分求wpring入门书
- struts问题? 急!
- sqlserver怎么分页?
- 为什么我在访问java包的时候会出错....请大虾指教....
- 神呀救救我呀 easy struts 的 Cannot find ActionMappings or ActionFormBeans collection 问题
- 请问weblogic8.1中有没有weblogic_sp.jar?我的JB9找不到他,我也找不到他
- java正则分割不是用两个反斜杠转义的吗 为啥我转义一个双引号 报错呢 lineString.split("\\"")
- 如何用struts1中的标签输出LIST里面存放的尸体类的值
- 有谁去搜狐面试过的,给传授点经验
我自己写出了。。不过太长了
相当于一个动态SQL的存储过程了。。
秀下你的成果,学习下。
for m=0 to ubound(itemValues)
if itemValues(m)="" then
exit for
end if
canshu=canshu+"∵item∴"+(m+1)+"、"+itemValues(m)
response.Write(canshu)
next
这是asp中的 改成java试试
这个在JAVA很好实现的,主要是要用查出来的数据做其他运算和统计,所以希望在数据直接做
with splitData as(
select *
from (select s.questionnum,
s.year,
decode(sign(t1.c_count),
1,
substr(s.answer, 1, t2.c_length),
0,
null,
null) a1,
decode(sign(t1.c_count - 1),
1,
substr(s.answer, t2.c_length + 3, t2.c_length),
0,
substr(s.answer, t2.c_length + 3, t2.c_length),
null) a2,
decode(sign(t1.c_count - 2),
1,
substr(s.answer, t2.c_length + 3, t2.c_length),
0,
substr(s.answer, t2.c_length + 3, t2.c_length),
null) a3
from ed_survey s,
(select t0.questionnum,
(length(t0.answer) -
length(replace(t0.answer, '@@', null))) / 2 c_count
from ed_survey t0
where regexp_like(t0.answer, '@@')) t1,
(select t.questionnum, instr(t.answer, '@@') - 1 c_length
from ed_survey t
where regexp_like(t.answer, '@@')) t2
where s.questionnum = t2.questionnum
and s.questionnum = t1.questionnum) checks), createData as (select d.questionnum,
d.year,
d.a1 answer
from splitData d
union all
select d.questionnum,
d.year,
d.a2 answer
from splitData d
union all
select d.questionnum,
d.year,
d.a3 answer
from splitData d)
select * from createData where answer is not null;由于现在需求最多只有15个连接,所以我直接写死了
我现在就想和大家讨论下能否把decode和union all这两个地方写活
要不以后需求一变,得改代码
去oracle开发版,点名要wildwave(狂浪)给你搞定。
select substring_index('a@@b@@c', '@@', 1)
union
select right(substring_index('a@@b@@c', '@@', 2),1)
union
select right(substring_index('a@@b@@c', '@@', 3),1);
:P 你可以看看这样有没有扩展的可能
MySQL的