zoukankan      html  css  js  c++  java
  • 步步为营-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))

    查出来有三处不一致

  • 相关阅读:
    wpf中防止界面卡死的写法
    wpf list<T>与ObservableCollection<T>的区别
    wpf 将对象按照正圆的顺序排列的写法
    .net 如何高效地使用string(转)
    wpf 查找DataTemplate中的控件的实现方式
    wpf 属性变更通知类的实现
    wpf 3D图形的实现(转)
    SpringBoot之HandlerInterceptorAdapter
    websocket简单实现
    mockjs基本使用
  • 原文地址:https://www.cnblogs.com/YK2012/p/9291031.html
Copyright © 2011-2022 走看看