模糊查询的SQL问题

bigmingming 2015-03-30 03:46:43
notes id
NULL DTHX15020500001
NULL DTHX15020900001
test345 DTHX15021500001
NULL DTHX15021500003
test123 DTHX15021600001
NULL DTHX15032300001
NULL HX15032600005
NULL HX15032600006

想模糊查找NOTEs不等于test123

NULL DTHX15020500001
NULL DTHX15020900001
test345 DTHX15021500001
NULL DTHX15021500003
NULL DTHX15032300001
NULL HX15032600005
NULL HX15032600006
...全文
120 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
满天飞雪No1 2015-03-30
  • 打赏
  • 举报
回复
with Cra as ( select NULL a ,'DTHX15020900001' b union all select 'test345' ,'DTHX15021500001' union all select NULL ,'DTHX15021500003' union all select 'test123', 'DTHX15021600001' ) select * from Cra where isnull(a,'') not like '%test123%'
Neo_whl 2015-03-30
  • 打赏
  • 举报
回复
为什么说是模糊,你要搜的内容比较准确啊,如果要查询notes中不包含test123参考如下:

           select notes,id from 表名
                                                   where notes is null or notes not like '%test123%'
还在加载中灬 2015-03-30
  • 打赏
  • 举报
回复
SELECT * FROM TB
WHERE notes IS NULL OR notes<>N'test123'
jingxiaoping 2015-03-30
  • 打赏
  • 举报
回复
select * from tablename where isnull(NOTEs,'')<>'test123'

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧