select * 
from  表 
where 字段 like '%小学' and 
       not like '%大学%' and 
       not like '%学院%' and 
       not like '%附属%'

解决方案 »

  1.   

    select * 
    from  表 
    where right(字段,2)='小学' and 
          charindex('大学',字段)=0 and 
          charindex('学院',字段)=0 and 
          charindex('附属',字段)=0
      

  2.   

    '小学'两个字占四个字节,不能用2
    select * from 表  where right(字段,4) and
     charindex('大学',字段)=0 and 
          charindex('学院',字段)=0 and 
          charindex('附属',字段)=0
      

  3.   

    小学'两个字占四个字节,不能用2
    select * from 表  where right(字段,4)='小学' and
     charindex('大学',字段)=0 and 
          charindex('学院',字段)=0 and 
          charindex('附属',字段)=0
      

  4.   

    RIGHT
    返回字符串中从右边开始指定个数的 integer_expression 字符。语法
    RIGHT ( character_expression , integer_expression ) 
    select right('我的小学',2)--结果
    /*
    ---- 
    小学(所影响的行数为 1 行)
    */
      

  5.   

    select * 
    from  表 
    where 字段 like '%小学' and 
           not like '%大学%' and 
           not like '%学院%' and 
           not like '%附属%'