当前位置: 代码迷 >> Sql Server >> 查询一列字段的中间字符解决方法
  详细解决方案

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

热度:146   发布时间:2016-04-27 15:32:26.0
查询一列字段的中间字符
我的数据库中有一个字段的内容是: <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)
  相关解决方案