注册 登录
编程论坛 SQL Server论坛

爆急!!!!!从商品信息表和用户表中查找相关字段然后添加到一张表中。。。。。

恋雪怜冰 发布于 2010-05-19 12:56, 536 次点击
从商品信息表和用户表中查找相关字段然后添加到一张BuyInfo表中,但写的sql中要加入中要添加一个新的字段,新的字段是BuyInfo中的字段,字段名是num,
sql语句如下:
insert into BuyInfo(
userID,username,telephone,area,Frxed_telephone,note,payment,address,realname,goodid,goodname,price,picture,type,unit,num)
select u.userid,u.username,u.telephone,u.area,u.Fixed_telephone,u.note,u.payment,u.address,u.realname,
       g.goodid,g.goodname,g.price,g.picture,g.type,g.unit
from goodinfo as g , users as u where userid=u.userid and goodid=g.goodid and g.goodid=2 and u.userid=1 and g.goodid=5

添加的num值写在哪个位置。
谢谢!请尽快帮助我。
2 回复
#2
aei1352010-05-19 13:16
就写在相应位置上啊
insert into BuyInfo(
userID,username,telephone,area,Frxed_telephone,note,payment,address,realname,goodid,goodname,price,picture,type,unit,num)
select u.userid,u.username,u.telephone,u.area,u.Fixed_telephone,u.note,u.payment,u.address,u.realname,
       g.goodid,g.goodname,g.price,g.picture,g.type,g.unit,'num值'
from goodinfo as g , users as u where userid=u.userid and goodid=g.goodid and g.goodid=2 and u.userid=1 and g.goodid=5
#3
恋雪怜冰2010-05-19 13:37
谢谢 解决了
1