Thaiki(泰麒) 如果用你的方法就要写成这样: where fieldname like '%3,1,1%' or fieldname like '%3,2,1%' or fieldname like '%3,3,1%' fieldname like '%3,4,1%'..... 好像不行
所以要分配处理 是0的就不能找了呀 是这个意思不 楼猪 0-0 create table test(id int,content varchar(50)) insert test select 1,'3,2,1|||3,0,1|||2,2,1|||' union all select 2,'3,1,1|||3,1,2|||2,2,1|||' union all select 3,'3,1,1|||3,2,2|||2,2,1|||' union all select 4,'3,2,1|||3,2,2|||2,2,1|||' union all select 5,'3,2,1|||3,2,2|||3,2,1|||' union all select 6,'5,2,1|||3,2,2|||3,2,1|||' goDeclare @S Nvarchar(4000) declare @shi varchar(10) declare @tin varchar(10) declare @wei varchar(10) Select @S = '3,0,1' select @shi = '5' --假设查找的是5室的 手动这里的值检查一下结果 select @tin = '0' --假设是0厅的 select @wei = '1' --假设是1卫的 --select * from test where content like '%3,0,1%' select * from test where CharIndex(','+ @shi + ',',',' + replace(content,'|||',','))>0 and CharIndex(','+ @wei + ',',',' + replace(content,'|||',','))>0 or CharIndex(','+ @tin + ',',',' + replace(content,'|||',','))>0 --加了个 or 这样也能找0的了 --复杂了 性能就不知道了 0-0
以下是MSSQL的
3,0,1
shi = 3 '室型
ting=0 '厅型 为0不查他!
wei =1 '卫型
假设3,2,1|||3,1,1|||2,2,1||| 的字段名为 Housetype
replace(Housetype,'|||',',')去掉|||并以','替换
sql = "select * from tab where CharIndex(','+ shi + ',',',' + replace(Housetype,'|||',','))>0 and CharIndex(','+ wei + ',',',' + replace(Housetype,'|||',','))>0"hoho,没试 应该可以
给分! 0-0
如house表中room字段存有"3,2,1|||3,1,1|||2,2,1|||"格式的数据,那么sql语句是select * from house where room regexp '3,[0-9],1';
好像不行
create table test(id int,content varchar(50))
insert test select 1,'3,2,1|||3,0,1|||2,2,1|||'
union all select 2,'3,1,1|||3,1,2|||2,2,1|||'
union all select 3,'3,1,1|||3,2,2|||2,2,1|||'
union all select 4,'3,2,1|||3,2,2|||2,2,1|||'
union all select 5,'3,2,1|||3,2,2|||3,2,1|||'
union all select 6,'5,2,1|||3,2,2|||3,2,1|||'
goDeclare @S Nvarchar(4000)
declare @shi varchar(10)
declare @tin varchar(10)
declare @wei varchar(10)
Select @S = '3,0,1'
select @shi = '5' --假设查找的是5室的 手动这里的值检查一下结果
select @tin = '0' --假设是0厅的
select @wei = '1' --假设是1卫的
--select * from test where content like '%3,0,1%'
select * from test where CharIndex(','+ @shi + ',',',' + replace(content,'|||',','))>0 and CharIndex(','+ @wei + ',',',' + replace(content,'|||',','))>0 or CharIndex(','+ @tin + ',',',' + replace(content,'|||',','))>0
--加了个 or 这样也能找0的了
--复杂了 性能就不知道了 0-0
0-0 ^-^我也不是高手 混混