日期:2014-05-18 浏览次数:20602 次
create table tb(no varchar(20)) insert into tb select '4008111111'union all select '4008111212'union all select '4008111234'union all select '4008225656'union all select '4008334567'union all select '4008256562'union all select '4008456700' --abcd select * 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 --aabb select * 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 1234 4008334567 3456 (2 行受影响) no no -------------------- ---- 4008111212 1212 4008225656 5656 4008256562 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
你参考。