首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

查询一列字段的中间字符解决方法

2012-03-04 
查询一列字段的中间字符我的数据库中有一个字段的内容是: pre aabbccddee /pre我想显示的时候显示的是

查询一列字段的中间字符
我的数据库中有一个字段的内容是: <pre> aabbccddee </pre>
我想显示的时候显示的是aabbccddee,请问SQL语句应该怎么写

[解决办法]
select substring(col , charindex( '> ' , col) + 1 , charindex( ' </ ' , col) - charindex( '> ' , col) - 1)
from tb
where charindex( '> ' , col) > 0 and charindex( ' </ ' , col) > 0 and charindex( ' </ ' , col) > charindex( '> ' , col)

热点排行