该查询为什么没有结果?? 解决接贴!!

iloveyoujia 2007-09-28 10:29:33
declare @t table( i int,a varchar(100))
insert into @t select 1,'中国 [2006] 1978'
union all select 2,'香港 [2007] 1997'

select * from @t where a like '%中国 [2006] 1978%'
...全文
198 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
tomyuansir 2007-10-06
  • 打赏
  • 举报
回复
10楼正解!!
xiangyu120 2007-10-06
  • 打赏
  • 举报
回复
龟兄也正解!!
xiangyu120 2007-10-06
  • 打赏
  • 举报
回复
1楼、5楼正解!!
yjlhch 2007-10-06
  • 打赏
  • 举报
回复
mark
iloveyoujia 2007-10-06
  • 打赏
  • 举报
回复
iloveyoujia 2007-10-06
  • 打赏
  • 举报
回复
iloveyoujia 2007-10-06
  • 打赏
  • 举报
回复
iloveyoujia 2007-10-06
  • 打赏
  • 举报
回复
iloveyoujia 2007-10-06
  • 打赏
  • 举报
回复
tomyuansir 2007-09-28
  • 打赏
  • 举报
回复
楼上高手都回答了 !!
giftzheng 2007-09-28
  • 打赏
  • 举报
回复

加[]就可以
select * from @t where a like '%中国 [[]2006[]]1978%'
$扫地僧$ 2007-09-28
  • 打赏
  • 举报
回复
declare @t table( i int,a varchar(100))
insert into @t select 1,'中国 [2006] 1978'
union all select 2,'香港 [2007] 1997'

select * from @t where charindex('中国 [2006] 1978',a)>0
chuifengde 2007-09-28
  • 打赏
  • 举报
回复
传进来的就:
select * from @t where charindex('中国 [2006] 1978',a)>0
dobear_0922 2007-09-28
  • 打赏
  • 举报
回复
--try1
select * from @t where a like '%中国 \[2006\] 1978%' escape '\'

--try2
select * from @t where a='中国 [2006] 1978'
dawugui 2007-09-28
  • 打赏
  • 举报
回复
declare @t table( i int,a varchar(100))
insert into @t select 1,'中国 [2006] 1978'
union all select 2,'香港 [2007] 1997'

select * from @t where charindex( '中国 [2006] 1978' , a) > 0

/*
i a
----------- ----------------
1 中国 [2006] 1978
(所影响的行数为 1 行)
*/
chuifengde 2007-09-28
  • 打赏
  • 举报
回复
or
select * from @t where a like '%中国 [[]2006] 1978%'

lwl0606 2007-09-28
  • 打赏
  • 举报
回复
[ ] 通配符
iloveyoujia 2007-09-28
  • 打赏
  • 举报
回复
escape 'Q' 是啥意思??

like '%%' 后面参数是传递进来的啊!!!
dawugui 2007-09-28
  • 打赏
  • 举报
回复
declare @t table( i int,a varchar(100))
insert into @t select 1,'中国 [2006] 1978'
union all select 2,'香港 [2007] 1997'

--加个N试试
select * from @t where a like N'%中国 [2006] 1978%'
chuifengde 2007-09-28
  • 打赏
  • 举报
回复
declare @t table( i int,a varchar(100))
insert into @t select 1,'中国 [2006] 1978'
union all select 2,'香港 [2007] 1997'

select * from @t where a like '%中国 Q[2006] 1978%' escape 'Q'

34,593

社区成员

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

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