求一sql语句或一存储过程!

firefox_1983 2005-09-07 11:54:54
现有两张表A,B,A表中有15600个14位的无序号码,B表中有2600个8位的无序号码,A,B号码个数之比为1:60,现想要实现从这个两个表中选取数据,插入到C表中,具体要求如下:
A,b表结构为 autoid,code
c表结构为:autoid,codenumber,brandnumber
目的结果:

68445305920005 12152777
............. 12152777
............. 12152777


..............................

41276038751199 85191671
............. 85191671
............. 85191671
.............................
其中68445305920005,41276038751199 是从A中选取的, 12152777,85191671是从B中选取的。一个B表中的号码要对应60个A中的号码,不知道我有没有说清楚,谢谢各位 !
...全文
136 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
vivianfdlpw 2005-09-07
  • 打赏
  • 举报
回复
insert C
select A.code
,B.brandnumber
from A
left join B on A.code=B.codenumber
monk188 2005-09-07
  • 打赏
  • 举报
回复
题目是什么意思!
在说清楚一点!
把,A,B表的结构描述具体点!
waterfirer 2005-09-07
  • 打赏
  • 举报
回复
alter table a add sid int identity(1,1)
alter table b add sid int identity(1,1)
insert C
select A.code
,B.brandnumber
from A,B where (A.sid+59)/60=B.sid
alter table a drop column sid
alter table b drop column sid

firefox_1983 2005-09-07
  • 打赏
  • 举报
回复
也许是我没有说清楚的缘故吧
现在我想实现的是C表中的内容codenumber 1-60个,61-120个...是从A表中选取的,此时的C表中的brandnumber分别是B表中的第1个,第2个,第2600个,每60个A中的号码对应B中的一个号码
wangdehao 2005-09-07
  • 打赏
  • 举报
回复
insert C
select A.code,B.brandnumber
from A,B
firefox_1983 2005-09-07
  • 打赏
  • 举报
回复
谁能帮我看看!
firefox_1983 2005-09-07
  • 打赏
  • 举报
回复
楼上的回答有问题,A,B表根本没有什么关联

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧