更新一列中的多行

时间:2019-06-12 19:37:01

标签: sql sql-server

因此,我希望能够使用每个唯一行的唯一值来更新一列中的多行。 I.E我想从另一个表中获取一个人的值,并用它替换密码,然后我希望能够批量这样做

我下面有代码。

Update PERSON

Set Person.PASSWD = CONTPOINT.FILEAS From CONTPOINT INNER JOIN PERSON on Person.SERIALNO = CONTPOINT.SERIALNO

WHERE CONTPOINT.CPTYPENO = 3 AND Person.SERIALNO in ('45822', '44281', '28241', '28241', '31415', '31415', '31415', '31415', '31415', '39318', '41677', '41681', '41682', '41683', '45604', '45604', '45713', '45807', '45807', '45822', '45822', '45822', '32808', '27435', '17665', '30109', '27111', '27111', '43114', '43114', '39097', '39097', '43574', '40114', '30787', '30787', '39096', '39095', '39095', '27137', '27135', '22003', '27135', '33532', '27136', '27134', '33532', '34085', '27134', '17515', '26152', '26152', '26152', '26152', '26152', '26152', '34902', '42296', '34903', '40538', '41599', '41599', '29586', '42236', '29585', '10436', '43119', '38967', '37942', '10625', '10625', '43580', '43580', '43579', '43579', '45386', '30838', '30838', '30838', '30838', '30838', '30838', '30838', '30838', '30838', '30842', '30842', '30841', '30841', '30841', '30841', '30841', '30841', '23488', '24142', '24142', '24142', '24142', '41358', '41358', '41358', '41358', '39538', '39538', '39538', '39538', '4280', '4280', '4280', '4280', '4280', '4280', '39353', '39352', '43758', '8134', '43758', '35447', '8135', '35447', '41019', '41019', '41019', '41019', '33624', '41107', '33624', '38185', '34810', '34810', '34810', '34810', '34810', '34810', '34030', '34289', '34289', '34289', '34289', '34289', '34289', '21508', '21508', '21508', '21508', '21508', '21508', '21508', '21508', '21508', '21760', '21508', '21508', '21508', '21508', '21508', '21508', '21508', '21508', '21508', '43980', '21509', '21509', '13229', '13229', '13229', '13229', '13229', '13229', '41932', '42585', '44781', '38865', '30354', '30354', '33307', '45397', '44752', '42731', '43490', '25466', '25466', '25466', '25466', '25466', '25466', '24230', '39453', '39453', '39453', '39453', '34522', '41595', '41595', '41595', '41594')

1 个答案:

答案 0 :(得分:0)

我想你想要这个:

UPDATE P
SET P.PASSWD = C.FILEAS
FROM Person P
JOIN CONTPOINT C ON P.SERIALNO = C.SERIALNO
WHERE ...

您的问题有点令人困惑,您应该添加将来当前查询存在的问题。 (包括任何错误消息)