读书人

一个 insert 插入 多表关联数据 小疑点

发布时间: 2012-01-23 21:57:28 作者: rapoo

一个 insert 插入 多表关联数据 小问题,搞了3个小时了
A表:

goodsid code
1 100001
2 100003
3 100002

B表:
code pty
100001 5
100002 13
100003 10

现想在C表中插入数据:
C表:

goodsid pty
1 5
2 10
3 13


俺搜索了 一些贴子,都是两表相关联,没有三表相关联的


实在搞不明白了


可否指点一下?

[解决办法]
insert into c(goodsid,pty) select a.goodsid,b.pty from a,b where a.code=b.code;

读书人网 >SQL Server

热点推荐