SQL字符串截取~ - .NET技术 / C#
数据库有个字段例:aaaaaa,bbbbb,cccccc有什么简单的方法分别取得aaaaaa,bbbbb和cccccc啊,因为他们是和其他表关联的ID,求各位高人指点下~在SQL里面直接能完成的方法~
没太清楚楼主的意思
把一列分成几行,然后join即刻
问题不明白
用循环截取也行的(while,substring)
这是一个例子 LZ看一下!
原始的字符串‘邮箱成功开通
Passwd=Nm,12345,Mailsize=30,Mailname=gtxx_lijie,Displayname=李洁,saa’
现在我们把Mailname和Displayname提取出来,以Displayname为例,大体思路是这样:把‘Displayname=’和前面的数据截取掉,留下后面的数据,
SQL:
Select SUBSTRING(subdesc,CHARINDEX('DISPLAYNAME',subdesc)+12,LEN(subdesc)-CHARINDEX('DISPLAYNAME',subdesc)) from SBMailSubUserLog where subtype like '%员工业务开通%' and mobile in (select distinct mobile from SBMailSubUserLog where subtype like '%员工业务关闭%' and changedate>='2009-01-01 00:32:24.327')
显示出来的就是这样’ 李洁,saa’现在再整理‘,’号之后的数据select left(subdesc,patindex('%,%', subdesc)) from SBMailSubUserLog,然后把它们整合起来,
Select left(SUBSTRING(subdesc,CHARINDEX('DISPLAYNAME',subdesc)+12,LEN(subdesc)-CHARINDEX('DISPLAYNAME',subdesc)),patindex('%,%',SUBSTRING(subdesc,CHARINDEX('DISPLAYNAME',subdesc)+12,LEN(subdesc)-CHARINDEX('DISPLAYNAME',subdesc))))
from SBMailSubUserLog
where subtype like '%员工业务开通%' and
mobile in
(select distinct mobile from SBMailSubUserLog where subtype like '%员工业务关闭%' and changedate&
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......
1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......
我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间
Id value state dattime
101 32.3 0 ......