本文介绍了从列 sql 中提取字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我在我的日志表中有一个名为 MESSAGE 的列,它的每一行都是这样开头的(好吧,至少它们都以百分比这个词开头):
So I have this column called MESSAGE on my LOGS Table that has every line starting like this (well, at least they all start with the word Percentage):
Percentage|15/25|1%*1569ms#0ms*C:\Snapshot\Snapshot_15.jpg
我需要选择字符串
1569ms
在这种情况下.它们总是介于 * 和 # 之间.我该怎么做?
in this case. They always come between * and #.How can I do this?
SELECT SUBSTRING(MESSAGE, , ) as Duration FROM LOGS
推荐答案
SELECT SUBSTRING(MESSAGE,
CHARINDEX('*',message)+1,
CHARINDEX('#',message)-CHARINDEX('*',message)-1) as Duration
FROM LOGS
这篇关于从列 sql 中提取字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!