日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

步步为营-104-SQL语句(截取字符串)

發布時間:2025/7/14 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 步步为营-104-SQL语句(截取字符串) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

按照指定字符截取字符串,截取出300

?

?業務需求:想比對圖片中框線部分是否一致

第一步 從最后一個/截取到末尾

select top 1 reverse(substring(reverse(ProcessControlName),1,charindex('/',reverse(ProcessControlName)) - 1)) from ProcessPublish;

--第二步 在第一步的基礎上從最后一個.截取
select RTRIM(LTRIM(reverse(substring(reverse(ProcessControlName),1,charindex('/',reverse(ProcessControlName)) - 1)))) as web端模板,RTRIM(LTRIM(reverse(substring(reverse(MobileFormTemplatePath),1,charindex('/',reverse(MobileFormTemplatePath)) - 1)))) as 手機端模板, *
from ProcessPublish
where ProcessID >2489 --新增加的"華濟建設"
and ProcessControlName != '' --模板不等于空,說明bpm發起的
and MobileFormTemplatePath != ''

?

--第三步 在第二步的基礎上獲取去掉.html字段
select top 1 (substring((substring(reverse(ProcessControlName),charindex('.',reverse(ProcessControlName))+1,len(reverse(ProcessControlName))-charindex('.',reverse(ProcessControlName)))),1,charindex('/',(substring(reverse(ProcessControlName),charindex('.',reverse(ProcessControlName))+1,len(reverse(ProcessControlName))-charindex('.',reverse(ProcessControlName))))) - 1)) from ProcessPublish

最后,完成

select (substring((substring(reverse(ProcessControlName),charindex('.',reverse(ProcessControlName))+1,len(reverse(ProcessControlName))-charindex('.',reverse(ProcessControlName)))),1,charindex('/',(substring(reverse(ProcessControlName),charindex('.',reverse(ProcessControlName))+1,len(reverse(ProcessControlName))-charindex('.',reverse(ProcessControlName))))) - 1)) as web端模板,
(substring((substring(reverse(MobileFormTemplatePath),charindex('.',reverse(MobileFormTemplatePath))+1,len(reverse(MobileFormTemplatePath))-charindex('.',reverse(MobileFormTemplatePath)))),1,charindex('/',(substring(reverse(MobileFormTemplatePath),charindex('.',reverse(MobileFormTemplatePath))+1,len(reverse(MobileFormTemplatePath))-charindex('.',reverse(MobileFormTemplatePath))))) - 1)) as 手機端模板, *
from ProcessPublish
where ProcessID >2489 --新增加的"華濟建設"
and ProcessControlName != '' --模板不等于空,說明bpm發起的
and MobileFormTemplatePath != ''
and (substring((substring(reverse(ProcessControlName),charindex('.',reverse(ProcessControlName))+1,len(reverse(ProcessControlName))-charindex('.',reverse(ProcessControlName)))),1,charindex('/',(substring(reverse(ProcessControlName),charindex('.',reverse(ProcessControlName))+1,len(reverse(ProcessControlName))-charindex('.',reverse(ProcessControlName))))) - 1)) != (substring((substring(reverse(MobileFormTemplatePath),charindex('.',reverse(MobileFormTemplatePath))+1,len(reverse(MobileFormTemplatePath))-charindex('.',reverse(MobileFormTemplatePath)))),1,charindex('/',(substring(reverse(MobileFormTemplatePath),charindex('.',reverse(MobileFormTemplatePath))+1,len(reverse(MobileFormTemplatePath))-charindex('.',reverse(MobileFormTemplatePath))))) - 1))

查出來有三處不一致

轉載于:https://www.cnblogs.com/YK2012/p/9291031.html

總結

以上是生活随笔為你收集整理的步步为营-104-SQL语句(截取字符串)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。