SQL插入数据出现重复的多条数据
语句为他是只出现一条insertintotb_account(owner_id,room_id,item_price_id,quantity,amount,created...
语句为他是 只出现一条insert into tb_account (owner_id,room_id,item_price_id,quantity,amount,createdt,curr_month,operator,flag,years,grdays,item_id,delaydate)
select owner_id,room_id,tb_account.item_price_id,quantity,quantity*Item_price,'2014-01-01 00:00:00','2014/08','楠丁','0','2013-2014','197','01','2014-8-01 00:00:00' from tb_account , ssss, Tb_support_price where owner_id=F1 and tb_account.item_price_id=Tb_support_price.Item_price_id
但是在最后加了 F2=‘2’就会出现3条重复的数据 展开
select owner_id,room_id,tb_account.item_price_id,quantity,quantity*Item_price,'2014-01-01 00:00:00','2014/08','楠丁','0','2013-2014','197','01','2014-8-01 00:00:00' from tb_account , ssss, Tb_support_price where owner_id=F1 and tb_account.item_price_id=Tb_support_price.Item_price_id
但是在最后加了 F2=‘2’就会出现3条重复的数据 展开
展开全部
t-sql
一次插入多条数据,除了复制其它表外, 只有重复地写insert. 如果有规律可以用WHILE 循环。
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc1')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc2')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc3')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc4')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc5')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc6')
.................
一次插入多条数据,除了复制其它表外, 只有重复地写insert. 如果有规律可以用WHILE 循环。
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc1')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc2')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc3')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc4')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc5')
insrt into GOODS (GoodsName,Price,AreaId)values('aaa','bbb','ccc6')
.................
追问
where owner_id=F1 and tb_account.item_price_id=Tb_support_price.Item_price_id是在这个后边加的条件 F2='2' 后就会出现重复的数据
展开全部
在语句加distinct去掉重复,语句:
insert into tb_account (owner_id,room_id,item_price_id,quantity,amount,createdt,curr_month,operator,flag,years,grdays,item_id,delaydate)
select distinct owner_id,room_id,tb_account.item_price_id,quantity,quantity*Item_price,'2014-01-01 00:00:00','2014/08','楠丁','0','2013-2014','197','01','2014-8-01 00:00:00' from tb_account , ssss, Tb_support_price where owner_id=F1 and tb_account.item_price_id=Tb_support_price.Item_price_id
and F2='2'
insert into tb_account (owner_id,room_id,item_price_id,quantity,amount,createdt,curr_month,operator,flag,years,grdays,item_id,delaydate)
select distinct owner_id,room_id,tb_account.item_price_id,quantity,quantity*Item_price,'2014-01-01 00:00:00','2014/08','楠丁','0','2013-2014','197','01','2014-8-01 00:00:00' from tb_account , ssss, Tb_support_price where owner_id=F1 and tb_account.item_price_id=Tb_support_price.Item_price_id
and F2='2'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询