我有一个表Table T如下
create table T
(
  a varchar(32),
  b varchar(32)
)其中,b中的全部元素都有一个前缀 'WO5',如会有这些元素'WO589080','WO512341234123','WO5DF52323','WO534234VAF'现在,我想对b的'WO5'后面的字段进行比较和输出,应该怎么做?
例如,我想输出b字段的'WO5'后面是89080的记录,其中,输出的结果中b列必须是显示89080而不是WO589080谢谢!

解决方案 »

  1.   

    select replace(b,'WO5','') from t
      

  2.   

    select right(b,len(b)-3) from t
      

  3.   

    SELECT SUBSTRING(B,3,LEN(B)-3) FROM TB
      

  4.   

    select stuff(col,1,3,'')
    from tb
      

  5.   

    replace不保险,会替换后面的select   stuff(b,1,3,'') as b   from   t
    where b like 'W05%'
      

  6.   

    select * from t where right(b,len(b)-3)='89080'
      

  7.   

    select *
    from tb
    where stuff(col,1,3,'')='89080'
      

  8.   

    select   case when b like 'W05%' then stuff(b,1,3,'') else b end as b   from   t这样完整了吧
      

  9.   


    --这个就是将所有B字段的前三个字符去掉的意思
    select stuff(b,1,3,'') from tb