按照指定字符截取字符串,截取出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))

查出来有三处不一致

步步为营-104-SQL语句(截取字符串)的更多相关文章

  1. sql 语句 截取字符串的两种方案

    方案一:使用内置的函数 SUBSTRING,CHARINDEX,LEN三个内置函数 理论: SUBSTRING语法   SUBSTRING ( value_expression , start_exp ...

  2. sql语句截取字符串

    Postgresql 当中有四种方式获取当前时间.  一:now()      通过now()获取的时间是最完整的时间,包括时区,秒也保留到了6位小数.      select now();     ...

  3. SQL Server截取字符串

    --SQL Server截取字符串 , Len('hello@163.com')) ,charindex('.','hello@163.com'))

  4. 在论坛中出现的比较难的sql问题:1(字符串分拆+行转列问题 SQL遍历截取字符串)

    原文:在论坛中出现的比较难的sql问题:1(字符串分拆+行转列问题 SQL遍历截取字符串) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方 ...

  5. mysql里面如何用sql语句让字符串转换为数字

    sql语句将字符串转换为数字默认去掉单引号中的空格,遇到空格作为字符串截止, SELECT '123 and 1=1' +0 结果为123 MySQL里面如何用sql语句让字符串的‘123’转换为数字 ...

  6. SQL注入截取字符串函数

    在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...

  7. Sql注入截取字符串常用函数

    在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...

  8. SQL Server截取字符串和处理中文技巧

    一 环境介绍 SQL  Server PRINT @@VERSION MicrosoftSQLServer2012-11.0.2100.60(X64) Feb10201219:39:15 Copyri ...

  9. sql 语句系列(字符串的遍历嵌入删除与统计)[八百章之第十一章]

    遍历字符串 我觉得首先要提出一个疑问: 一个数据库本身就是用于存储的,遍历字符串究竟有何意义? 先看如何实现的,毕竟sql service 是没有for循环,也没有loop和while的. selec ...

随机推荐

  1. light oj 1011 - Marriage Ceremonies

    题目大意: 给出n*n的矩阵Map,Map[i][j]代表第i个男人和第j个女人之间的满意度,求男女一一配对后,最大的满意度之和. 题目思路:状态压缩 题目可看做每行取一点,所有点不同列的情况下,各个 ...

  2. html超文本标记语言基础一

    1,基本格式 <!DOCTYPE html> //声明为 HTML5 文档 <html> <head> <meta charset="utf-8&q ...

  3. zookeeper的ACL权限控制

    ACL:Access Control List  访问控制列表 1.  简介 0.概述 ACL 权限控制,使用:scheme:id:perm 来标识,主要涵盖 3 个方面: 权限模式(Scheme): ...

  4. HDOJ 3308 LCIS (线段树)

    题目: Problem Description Given n integers.You have two operations:U A B: replace the Ath number by B. ...

  5. 【转】Python之系统交互(subprocess)

    [转]Python之系统交互(subprocess) 本节内容 os与commands模块 subprocess模块 subprocess.Popen类 总结 我们几乎可以在任何操作系统上通过命令行指 ...

  6. Eclipse下egit插件的使用

    接触GIT已经很久了,但碰到的公司一直都在使用SVN,并因为各种理由拒绝换成GIT.今年换了份工作,乘着搭建公司新框架和项目的机会,总算在正式项目上使用了GIT.GIT的服务器直接就用了https:/ ...

  7. 网页块元素定位建议使用的xpath方式

    取上图的新手上路文字 使用xpath "//div[@class='pbm mbm bbda cl']//li[contains(string(),'用户组')]/span/a/text() ...

  8. leetcode 307 Range Sum Query

    问题描述:给定一序列,求任意区间(i, j)的元素和:修改任意一元素,实现快速更新 树状数组 树状数组的主要特点是生成一棵树,树的高度为logN.每一层的高度为k,分布在这一层的序列元素索引的二进制表 ...

  9. Go Rand小结

    对于Random的使用,在业务中使用频率是非常高的,本文就小结下常用的方法: 在Golang中,有两个包提供了rand,分别为 "math/rand" 和 "crypto ...

  10. emoji错误:ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect string value:

    1 前言 由于mysql数据库要存储微信昵称,但是当微信昵称带有emoj表情会出现标题的错误. 然后发现是emoj编码是4个字节保存的,于mysql数据库编码格式utf8默认保存的是1到3个字节. 2 ...