要查询"小学"结尾,但不能含有"大学"和"学院"、"附属"字样的记录,如何用一个语句完成? select * from 表 where 字段 like '%小学' and not like '%大学%' and not like '%学院%' and not like '%附属%' 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from 表 where right(字段,2)='小学' and charindex('大学',字段)=0 and charindex('学院',字段)=0 and charindex('附属',字段)=0 '小学'两个字占四个字节,不能用2select * from 表 where right(字段,4) and charindex('大学',字段)=0 and charindex('学院',字段)=0 and charindex('附属',字段)=0 小学'两个字占四个字节,不能用2select * from 表 where right(字段,4)='小学' and charindex('大学',字段)=0 and charindex('学院',字段)=0 and charindex('附属',字段)=0 RIGHT返回字符串中从右边开始指定个数的 integer_expression 字符。语法RIGHT ( character_expression , integer_expression ) select right('我的小学',2)--结果/*---- 小学(所影响的行数为 1 行)*/ select * from 表 where 字段 like '%小学' and not like '%大学%' and not like '%学院%' and not like '%附属%' 怎样检验字符串存储到ntext字段的有效性? 请问下列情况,哪种效率高些? 两个数值比较,条件是不相等,可结果中有相等数值的情况。 SQL优化的问题,高手请入!! 一个存储过程大家看看应该如何写. 问问:服务器CPU占50%,每一个数据库请求都这样,有经验的朋友答? 如何搜索一个字段在改列中啊 同种触发器的顺序在哪儿设置啊 郁闷!散分~~ sql server 存储过程 游标 数据导入的问题 求助:数据统计中的遇到的一个难题~~
from 表
where right(字段,2)='小学' and
charindex('大学',字段)=0 and
charindex('学院',字段)=0 and
charindex('附属',字段)=0
select * from 表 where right(字段,4) and
charindex('大学',字段)=0 and
charindex('学院',字段)=0 and
charindex('附属',字段)=0
select * from 表 where right(字段,4)='小学' and
charindex('大学',字段)=0 and
charindex('学院',字段)=0 and
charindex('附属',字段)=0
返回字符串中从右边开始指定个数的 integer_expression 字符。语法
RIGHT ( character_expression , integer_expression )
select right('我的小学',2)--结果
/*
----
小学(所影响的行数为 1 行)
*/
from 表
where 字段 like '%小学' and
not like '%大学%' and
not like '%学院%' and
not like '%附属%'