sql得到列的最末位字符

解决方案 »

  1.   

    select right(字段,1) from tb
      

  2.   

    select right(ltrim(colname),1) from tablename
      

  3.   

    select substring(字段,len(字段),1) from tb
      

  4.   

    select right(ltrim(字段名),1) from 表
      

  5.   

    create table tb(col varchar(10))
    insert into tb select 'abcdefg' union all select 'ghijklm'
    go
    select left(REVERSE(col),1) from tb
    /*
    ----
    g
    m(2 行受影响)*/
    go
    drop table tb
      

  6.   

    select * from table where SUBSTRING([列名],LEN([列名])-1,2)='条件'
    求鉴定
      

  7.   


    select substring(reverse('acb'),1,1)
      

  8.   


    declare @table table (colname varchar(14))
    insert into @table
    select 'aaaa条件' union all
    select 'bbbb' union all
    select 'cccc条件' union all
    select 'dddd'select * from @table where substring(colname,len(colname)-1,2)='条件'
    /*
    colname
    --------------
    aaaa条件
    cccc条件
    */
    select * from @table where right(colname,2)='条件'
    /*
    colname
    --------------
    aaaa条件
    cccc条件
    */