好像要在sql中使用正则,请会正则的大侠帮帮忙。
解决方案 »
- 使用curl模拟post数据出现“未将对象引用设置到对象的实例”错误
- PHP论坛精华帖聚合上线啦
- 无退出,居然也自动退出session了
- jpgraph的问题: 很奇怪,同样的程序在windows上可以显示中文,在linux上就不行了,怎么回事?
- php获取到两个ip
- 关于mysql_connect函数的求助!!!
- ??????菜鸟求助,为什么我写的php不能传递参数啊??????????????????
- 请帮我看一下,为什么用PHP后缀名就提示JS错误,而用HTML格式的就没有问题??
- 现在还能不能找到兼职的工作?
- 菜鸟问下用户权限问题,求大神回答!
- [求助!]关于SMARTY的模板资源来源问题!
- 请问smarty里面怎么重复显示指定次数的字符?
以下是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 ^-^我也不是高手 混混