SqlServer中批量update

时间:2023-03-09 04:14:48
SqlServer中批量update

现在我有两张表分别是S_PERSON,S_USER

S_PERSON

SqlServer中批量update

S_USER

SqlServer中批量update

我现在想把S_USER表中的ACCOUNT批量修改成S_PERSON的ACCOUNT

我们可以发现S_USER表中有个跟S_PERSON表关联的字段 那就是PERSON_ID 这也是我们要update的条件

找到这个关系以后我们就不难写sql了

update S_USER set account=p.account from S_PERSON p where p.id=S_USER.person_id;

结果为:

SqlServer中批量update