我有以下查询,它允许我按行号连接两个表,我正在尝试修改它,以便它使用随机名称表中的随机名称更新订阅者表。
select fo.*, so.*
from (select *,
row_number() over (order by FirstName) as rn
from randomnames
) fo
join (select *,
row_number() over (order by ID) as rn
from subscribers) so on fo.rn = so.rn
我将其更新为以下内容以使其正常工作
update subscribers set
FirstName = fo.Firstname,
LastName = fo.LastName
from
(select *,
row_number() over (order by firstname) as rn
from _randomnames
) fo
join (select *,
row_number() over (order by ID desc) as rn
from subscribers) so on fo.rn = so.rn
where so.ID = subscribers.ID