各位好! 请问如何把一个表的数据更新啊?以下是我写的一小段程序,有错误,不知道怎么写。
update podetailtest set deliveryQty=(select tdeliveryqty from test)
where podetailtest.LineItemNo=test.LineItemno
and podetailtest.refkey=test.refkey
and podetailtest.PartNo_by=test.PartNo_by 这样错在那里啊?谢谢!
update podetailtest set deliveryQty=(select tdeliveryqty from test)
where podetailtest.LineItemNo=test.LineItemno
and podetailtest.refkey=test.refkey
and podetailtest.PartNo_by=test.PartNo_by 这样错在那里啊?谢谢!
from TEST
where podetailtest.LineItemNo=test.LineItemno
and podetailtest.refkey=test.refkey
and podetailtest.PartNo_by=test.PartNo_by
如果你的test表中有多条记录,会引起错误
deliveryQty in (select tdeliveryqty from test)
这样试试
from podetailtest a,test b
where a.LineItemNo=b.LineItemno
and a.refkey=b.refkey
and a.PartNo_by=b.PartNo_by
where podetailtest.LineItemNo=test.LineItemno
and podetailtest.refkey=test.refkey
and podetailtest.PartNo_by=test.PartNo_by
where podetailtest.LineItemNo=test.LineItemno
and podetailtest.refkey=test.refkey
and podetailtest.PartNo_by=test.PartNo_by )
改成
=(select top 1 tdeliveryqty from test)
不知道行不行,还有就是如果这句没有符合条件的记录呢
update podetailtest
set deliveryQty=t.tdeliveryqty
from podetailtest p inner join test t
on p.LineItemNo=t.LineItemno and p.refkey=t.refkey and p.PartNo_by=t.PartNo_by