本文介绍了更新语法有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SQL的新手,无法弄清楚如何更新我的表

(StoreItemStatus),其中包含每个项目的当前状态

store(STORE_KEY,ITEM_KEY,STATUS,...)。

我在表格中获得更新的状态信息(我称之为NewInfo)

有类似的字段。 NewInfo可能包含每个

商店/项目的多个记录,但我将使用最新状态。我不确定如何使用NewInfo的每条记录更新StoreItemStatus

。任何建议都是

非常感谢


谢谢,

Paul

I''m new to SQL and can''t figure out how to update my table
(StoreItemStatus) that contains the current status for items in each
store (STORE_KEY, ITEM_KEY, STATUS,...).
I get updated status info in a table (I''ll call it NewInfo) that
has similar fields. NewInfo may contain multiple records for each
Store/Item, but I will just use the latest status. I''m not sure how
to update StoreItemStatus using each record of NewInfo. Any advice is
greatly appreciated

Thanks,
Paul

推荐答案





大卫,


除非OP确定每个Store / Item组合在NewInfo表中至少有一行

行,否则他最好添加


WHERE EXISTS

(SELECT *

来自NewInfo

WHERE store_key = StoreItemStatus.store_key

AND item_key = StoreItemStatus.item_key)


来自这个查询。


Best,Hugo

-


(删除_NO_和_SPAM_以获取我的电子邮件地址)



Hi David,

Unless the OP is sure that every Store / Item combination has at least one
row in the NewInfo table, he''d better add

WHERE EXISTS
(SELECT *
FROM NewInfo
WHERE store_key = StoreItemStatus.store_key
AND item_key = StoreItemStatus.item_key)

to this query.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)



这篇关于更新语法有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 02:20