select * from yourtablename
where
REVERSE(substring (
REVERSE(UserInfo),
charindex('|||',REVERSE(UserInfo))+3 ,
charindex('|||',REVERSE(UserInfo),charindex('|||',REVERSE(UserInfo))+1)
-charindex('|||',REVERSE(UserInfo))-3 )) ='1500以上'
where
REVERSE(substring (
REVERSE(UserInfo),
charindex('|||',REVERSE(UserInfo))+3 ,
charindex('|||',REVERSE(UserInfo),charindex('|||',REVERSE(UserInfo))+1)
-charindex('|||',REVERSE(UserInfo))-3 )) ='1500以上'
where reverse(UserInfo) like '%|||上以0051|||%'
where reverse(UserInfo) like '%[^|]%|||上以0051|||%'
where right(UserInfo,charindex('|||',reverse(UserInfo),charindex('|||',reverse(UserInfo))+2)) like '|1500以上|||%'
没查到,为什么
REVERSE(left(substring(REVERSE(userinfo),charindex('|||',REVERSE(userinfo))+3,len(userinfo)),charindex('|||',substring(REVERSE(userinfo),charindex('|||',REVERSE(userinfo))+3,len(userinfo)))-1))='1500以上'
'%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%'查不出
where userinfo like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%'
and userinfo not like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%|||%'
where userinfo like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%'
and userinfo not like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%|||%'这样不可以应为and userinfo not like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%|||%'条件的数据也要查的。
select Userinfo from [dv_user] where userinfo like
'%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||%[^|]%|||1500以上|||%[^|]%|||%[^|]%'不知道为什么查不
(
select userinfo='1|||多重性格, 活泼可爱, 聪明伶俐||||||||||||||||||||||||||||||大学|||||||||3|||500-1000|||广告|||文化/教育/育儿, 其他|||200-500|||500-800|||800-1500|||1500以上|||2'
union all select '何|||多重性格, 乐天达观, 幼稚调皮, 温柔体贴|||||||||黑龙江|||哈尔滨|||鸡|||AB|||回教|||零售商/手工工人|||未婚|||高中||||||||||||5000以上|||其它|||其他|||1500以上|||1500以上|||800-1500|||1500以上|||230802'
)a
where userinfo like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%'
and userinfo not like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%|||%'/*--结果:Userinfo
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1|||多重性格, 活泼可爱, 聪明伶俐||||||||||||||||||||||||||||||大学|||||||||3|||500-1000|||广告|||文化/教育/育儿, 其他|||200-500|||500-800|||800-1500|||1500以上|||2
何|||多重性格, 乐天达观, 幼稚调皮, 温柔体贴|||||||||黑龙江|||哈尔滨|||鸡|||AB|||回教|||零售商/手工工人|||未婚|||高中||||||||||||5000以上|||其它|||其他|||1500以上|||1500以上|||800-1500|||1500以上|||230802(所影响的行数为 2 行)
--*/
少写一个'|||'
其实这样就是我的意思select Userinfo from --[dv_user]
(
select userinfo='1|||多重性格, 活泼可爱, 聪明伶俐||||||||||||||||||||||||||||||大学|||||||||3|||500-1000|||广告|||文化/教育/育儿, 其他|||200-500|||500-800|||800-1500|||1500以上|||2'
union all select '何|||多重性格, 乐天达观, 幼稚调皮, 温柔体贴|||||||||黑龙江|||哈尔滨|||鸡|||AB|||回教|||零售商/手工工人|||未婚|||高中||||||||||||5000以上|||其它|||其他|||1500以上|||1500以上|||800-1500|||1500以上|||230802'
)a
where userinfo like '%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||%|||1500以上|||%'