步步为营-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))
查出来有三处不一致
步步为营-104-SQL语句(截取字符串)的更多相关文章
- sql 语句 截取字符串的两种方案
方案一:使用内置的函数 SUBSTRING,CHARINDEX,LEN三个内置函数 理论: SUBSTRING语法 SUBSTRING ( value_expression , start_exp ...
- sql语句截取字符串
Postgresql 当中有四种方式获取当前时间. 一:now() 通过now()获取的时间是最完整的时间,包括时区,秒也保留到了6位小数. select now(); ...
- SQL Server截取字符串
--SQL Server截取字符串 , Len('hello@163.com')) ,charindex('.','hello@163.com'))
- 在论坛中出现的比较难的sql问题:1(字符串分拆+行转列问题 SQL遍历截取字符串)
原文:在论坛中出现的比较难的sql问题:1(字符串分拆+行转列问题 SQL遍历截取字符串) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方 ...
- mysql里面如何用sql语句让字符串转换为数字
sql语句将字符串转换为数字默认去掉单引号中的空格,遇到空格作为字符串截止, SELECT '123 and 1=1' +0 结果为123 MySQL里面如何用sql语句让字符串的‘123’转换为数字 ...
- SQL注入截取字符串函数
在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...
- Sql注入截取字符串常用函数
在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...
- SQL Server截取字符串和处理中文技巧
一 环境介绍 SQL Server PRINT @@VERSION MicrosoftSQLServer2012-11.0.2100.60(X64) Feb10201219:39:15 Copyri ...
- sql 语句系列(字符串的遍历嵌入删除与统计)[八百章之第十一章]
遍历字符串 我觉得首先要提出一个疑问: 一个数据库本身就是用于存储的,遍历字符串究竟有何意义? 先看如何实现的,毕竟sql service 是没有for循环,也没有loop和while的. selec ...
随机推荐
- Linux系统安全学习笔记(1)-- 文件系统类型
今天看了一个关于Linux系统安全的视频教程,这个教程有很多的知识点,我会分几篇博文将我的笔记分享出来. 首先是关于Linux文件系统类型的一些知识,Linux有四种常见的文件系统类型(网上大多数是3 ...
- 【运维】浪潮服务器一块硬盘显示红色Offline(或者Failed)解决办法
[写在前面] 最近服务器不知道为什么总是出现故障,以前戴尔服务器硬盘出现故障,也就是说硬盘旁边的灯显示为红色的时候,一般情况下都是表示硬盘坏掉了,直接买一块新的硬盘,将坏掉的硬盘拿 ...
- MK64FN1M0xxx12_flash.ld链接文件解析
1.前言 本文主要对MK64FN1M0xxx12_flash.ld文件进行分析,以此来加深对链接文件的理解 2.文件详解 /* ** ################################# ...
- Linux虚拟机安装及环境搭建
1.下载centos,地址:https://www.centos.org/download/ 下载时选择DVD ISO 2.使用VMware Workstation进行安装. 3.虚拟机网络配置 ...
- 利用iscroll实现上拉加载下拉刷新
1.首先引用isScroll插件 说明:页面加载时初始化isScroll,然后调用pullDownAction()和pullUpAction(),每次切换tab时,只需要对pullDownAction ...
- proxyTable设置代理解决跨域问题
应用场景:在不同域之间访问是比较常见,在本地调试访问远程服务器....这时就有域问题. 解决方案一:在config里面的index.js里面的proxyTable //这里理解成用‘/api'代替ta ...
- jquery源码解析
//局部作用域,外部引用不到这个闭合函数里面的东西,这时候需要用提供的对外访问接口来访问里面的变量 (function(){ ; function $() { alert(a) } window.$ ...
- leetcode327 Count of Range Sum
问题描述: 给定一个整数数组nums,返回其所有落在[low, upper]范围内(包含边界)的区间和的数目. 区间和sums(i, j)的定义为所有下标为i到j之间(i ≤ j)的元素的和,包含边界 ...
- $Django Rest Framework-序列化组件
1 序列化组件 e=serializers.SerializerMethodField() # 方法名:叫get_字段名, 参数,返回字典 def get_e(self,obj): #obj为b ...
- PHP一维数组转二维数组正则表达式
2017年11月20日17:17:08 array(1 => '哈哈') 变成 array('id' => 1, 'name' => '哈哈') 查找目标: (\d)\s=&g ...