所以基本上这将是伪代码,但我不知道如何在SQL中执行此操作,请帮忙.
for each row in table1{
loop through each row in table 2 {
if table1's row.column 1 = table2's row.column 2 for this row {
set table1's row.col2 = table2's row.col2
}
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:好的,让我更具体一点.我们基本上从hibernate序列切换为id,使用guid作为id列.我正在尝试通过创建前一个外键列的临时更新相关的外键,然后匹配临时列以更新实际列.
假设表1有id,而表2有一列用于将这些id用作外键.我想使用表2中的先前值与表1中的行匹配,并设置表2中的键值以匹配表1的新guid.
所以表2可能有多行重复的id,但表1永远不会有重复.如果那有意义的话.