1.
数据
56A4
56A4
56AA0A
56AA1A
值的位数是固定的,我想where出前面三位包含'56A',又是56AA01A格式的数据,where怎么写2.
数据
56G10N我想where出包含56g的怎么写?

解决方案 »

  1.   

    1、
    --用临时表的id int identity,生成序号,得到前3个即可。
    2、
    select * from tablename where 数据 like '%56g%'
      

  2.   


    declare @table table (数据 varchar(6))
    insert into @table
    select '56A4' union all
    select '56A4' union all
    select '56AA0A' union all
    select '56AA1A'create table #t (id int identity,数据 varchar(6))
    insert into #t select * from @table
    select top 3 * from #t where left(数据,3)='56A' order by id
    /*
    id          数据
    ----------- ------
    1           56A4
    2           56A4
    3           56AA0A
    */
    drop table #t
      

  3.   

    --1.值的位数是固定的,我想where出前面三位包含'56A',又是56AA01A格式的数据,where怎么写
    select * from tb where 列名 like '56A%' and len(列名)=len('56AA01A')
    --2.我想where出包含56g的怎么写
    select * from tb where 列名 like '56g%'
      

  4.   

    1
    where 数据 ='56AA01A'
    2
    where 数据 like '%56g%'
      

  5.   

    --2.我想where出包含56g的怎么写,如果56g前面也有值的化,那么就按一楼老王大哥那样操作
    select * from tablename where 数据 like '%56g%'