zoukankan      html  css  js  c++  java
  • sql语句收藏

    收集自网络,方便自己,方便他人

     1 if object_id('[aaa]') is not null drop table [aaa]
     2 go
     3 create table [aaa]([地区] varchar(4),[内容] varchar(45))
     4 insert [aaa]
     5 select '中国','021sp.html|管材|4355;028sp.html|建筑材料|3209' union all
     6 select '中国','023sp.html|材|4356;025sp.html|建|9209'
     7 go
     8  
     9 select  a.地区,
    10  内容=substring(a.内容,b.number,charindex(';',a.内容+';',b.number)-b.number)
    11 from [aaa] a
    12 join master..spt_values b on b.type='P'
    13 where charindex(';',';'+a.内容,b.number)=b.number
    14  
    15 /**
    16 地区   内容
    17 ---- ---------------------------------------------
    18 中国   021sp.html|管材|4355
    19 中国   028sp.html|建筑材料|3209
    20 中国   023sp.html|材|4356
    21 中国   025sp.html|建|9209
    22  
    23 (4 行受影响)
    24 **/
    按分隔符拆分记录
    1 select id, len(nr) - len(replace(nr,'a' , '')) from temp
    字段中字符串出现次数
  • 相关阅读:
    typescript
    js-解决安卓手机软键盘弹出后,固定定位布局被顶上移问题
    vue
    js
    Object.assgin基本知识与相关深浅拷贝
    js-工具方法(持续更新)
    vue
    vue
    git
    css
  • 原文地址:https://www.cnblogs.com/knightyj/p/5888824.html
Copyright © 2011-2022 走看看