So basically it will be psuedo code, but I donβt know how to do it in SQL, please help.
for each row in table1{ loop through each row in table 2 { if table1 row.column 1 = table2 row.column 2 for this row { set table1 row.col2 = table2 row.col2 } } }
Edit: Ok, let me be more specific. We basically switch from the hibernation sequence as id to using the guidance for the id column. I am trying to update foreign keys associated with creating a temporary column of the previous foreign key column, and then matching temporary columns to update the actual columns.
Suppose that in table one there was an identifier, and in table two there was a column for these identifiers to be used as foreign keys. I want to use the previous values ββin table 2 to match the rows in table 1 and set the key values ββin table 2 to match the new pointer to table 1.
therefore, table 2 may contain multiple rows of duplicate id, but in table 1 there will never be duplicates. If that makes sense.
sql mysql sql-server
hthomos
source share