我想要查询以“M”开头并以“N”结束的所有字段,请问下怎么解决?

解决方案 »

  1.   

    select * from 表 where 字段 like 'M%N'
      

  2.   

    所有字段?记录:字段 like 'M%N'
      

  3.   

    declare @t table(code varchar(20))
    insert into @t select 'MN'
    insert into @t select 'MNN'
    insert into @t select 'MSN'
    insert into @t select 'MNS'
    insert into @t select 'M))))N'
    insert into @t select ',MasdfasdfN'select * from @t where code like 'M%N'
      

  4.   

    --查询所有字段?还是从所有字段里查询呢?
    select a.name as 表名,b.name as 字段名
    from sysobjects a left join syscolumns b on a.id = b.id
    where a.xtype = 'u' and b.name like 'M%N'
      

  5.   

    select b.name 字段名 
    from sysobjects a ,syscolumns b
    where a.id=b.id and a.xtype = 'u' and b.name like 'M%N'
      

  6.   


    colname like 'M%N'
    問個題外話:
    right(colname , 1) = 'N' and colname like 'M%' 
    執行的效果相同嗎 ?  效率也一樣嗎?