急求一条SQL,大侠请帮忙!!
表一: 表二:
seg are 13565168169
1368991 994 13565169445
1362995 994 13565169557
1368990 994 13565171385
1390993 993 13565171849
1399976 909 13565172740
1366758 903 13565173179
1364994 903 13565173680
1365756 997 13565176671
1365757 997 13565179297
1365758 997 13565180206
1368998 990 13565183144
1389935 902 13565186524
1366755 996 13565187950
1356527 901 13565189237
1377929 903 13565189395
1367752 992 13565189763
1380991 991 13565193536
1389934 902 13565196811
13565196839
13565199888
13565200385
13565200868
13565201491
13565205732
13565209584
要通过 表一的 arg 字段 查到 表二中对应的号码 如:区域为992 的所有号码,表一中的seg 是表二 字段的前几位号码!
哪位大侠能帮我解决啊! 解出及给分!
------解决方案--------------------select 表二.number from t2
where floor(表二.number/10000)=
(select 表一.seg from 表一 where 表一.arg=992);
------解决方案--------------------select tablename2.celnumber from tablename1,tablename2 where (LEFT(tablename2.celnumber,7) = tablename1.seg and tablename1.arg = 992);
------解决方案--------------------celnumber,arg,seg都用varchar型,如果是数值型请修改(LEFT(tablename2.celnumber,7) = tablename1.seg 部分