UPDATE master as m
SET m.husband = p.id
From per as p
where m.drid = p.drid AND p.address > 80000 AND p.address <= 154969
我有一个名为per
的表,其中包含名为id
的列。基本上,我想在master
子句中的另一个名为where
的表中复制这些ID。
但是我收到一个错误说,列&#34; m&#34;关系&#34;主人&#34;不存在。 m不是专栏。我不确定我哪里出错了?
答案 0 :(得分:4)
尝试如下;从m
操作中删除表格别名SET
并将其设为SET husband = p.id
UPDATE master m
SET husband = p.id
From per p
where m.drid = p.drid
AND p.address > 80000
AND p.address <= 154969
(OR)完全不使用表别名
UPDATE master
SET husband = per.id
From per
where master.drid = per.drid
AND per.address > 80000
AND per.address <= 154969