我有一个电话号码表,
比如:
BigCodeTable
4008111111 (AAAA)
4008111212 (ABAB)
4008111234 (ABCD)
4008222222 (AAAA)
4008225656 (ABAB)
4008334567 (ABCD)
4008256562 (ABAB)
4008456700 (ABCD)
我要实现按规则查找.
规则1 ABAB 类的.
查出结果为4008111212 4008225656 4008256562
规则2 ABCD类的
查出结果为4008111234 4008334567 4008456700
等其他规则..
------解决方案--------------------
表結構是怎麼樣,你上面的數據是一個字段,還是放在兩個字段?
------解决方案--------------------
vfp9.0
use BigCodeTable
index on 类 tag 类
brow
sele * from BigCodeTable order by 类
楼主真的是问这个问题吗?
------解决方案--------------------
这个查不了
存的时候要指定规则存储 ,比如标记字段
13989881231 AABB
13945551212 AABB
------解决方案--------------------
读出来解析
或者分11个字段分开存
------解决方案--------------------
------解决方案--------------------
表述能力太差,你的AAAA,ABAB是什么规则,你一共有哪些类别
这些关键问题要表述清楚。
------解决方案--------------------
4008256562 (ABAB)
4008456700 (ABCD)
怎么归类的?你的规则估计比较复杂,但是你又想在导入时一个语句搞定,你自己不觉得矛盾吗
------解决方案--------------------
- SQL code
create table tb(no varchar(20))insert into tbselect '4008111111'union allselect '4008111212'union allselect '4008111234'union allselect '4008225656'union allselect '4008334567'union allselect '4008256562'union allselect '4008456700'--abcdselect * from tb a,(select '1234' as no union select '2345' union select '3456' union select '3456' union select '5678' union select '6789' union select '7890' union select '0123') b where charindex(b.no,a.no)>0--aabbselect * from tb a,(select '1212' as no union select '2323' union select '3434' union select '4545' union select '5656' union select '6767' union select '7878' union select '8989') b where charindex(b.no,a.no)>0/*no no-------------------- ----4008111234 12344008334567 3456(2 行受影响)no no-------------------- ----4008111212 12124008225656 56564008256562 5656
------解决方案--------------------
这个 用 SQL比较难吧 因为你的规则没有定好
------解决方案--------------------
是右边最后4位数字?
vfp9.0
alter table BigCodeTable add column right1 c(1)
alter table BigCodeTable add column right2 c(1)
alter table BigCodeTable add column right3 c(1)
alter table BigCodeTable add column right4 c(1)
use BigCodeTable
repl right1 with right(BigCode,1) all
repl right2 with substr(BigCode,9,1) all
repl right3 with substr(BigCode,8,1) all
repl right4 with substr(BigCode,7,1) all
aaaa类:
sele * from BigCodeTable where right1=right2=right3=right4
aabb:
sele * from BigCodeTable where right1=right2 and right3=right4
abcd:
sele * from BigCodeTable where right1!=right2 and right2!=right3 and right3!=right4
你参考。