如何在SQL Server Compact Edition中基于多个表更新行?
我在数据库中有两个表。 ActivatedProducts和DocumentSettings.I在DocumentSettings表中添加了新列(UID),我想从ActivatedProducts表中放置来自ActivatedProducts(ID)表的UID数据
以下查询也无效,请帮帮我
UPDATE DocumentSettings
SET UID =
(
SELECT ActivatedProducts.ID
FROM ActivatedProducts
WHERE DocumentSettings.TitleID = ActivatedProducts.ProductID
)
UPDATE A
SET A.UID = B.ID
FROM DocumentSettings A, ActivatedProducts B
WHERE A.TitleID = B.ProductID
UPDATE DocumentSettings
SET [UID]=AP.[ID]
FROM DocumentSettings DS
INNER JOIN ActivatedProducts AP ON DS.[Titleid]=AP.[ProductID]
答案 0 :(得分:3)
我上次检查时,SQL Server CE 仍然不支持UPDATE-FROM-JOIN语法。您显示的所有3个都将在Sql Server中正常工作,但在CE中,您需要以编程方式检索每个值以便在循环中进行更新。
答案 1 :(得分:-2)
您可以按照以下
进行操作 UPDATE [table one]
SET [table one].result = [table two] .results
FROM [table one] T1
INNER JOIN [table three] t3
on t1.reg_id = t3.reg_id
INNER JOIN [table two] T2
on t2.venue = t3.venue