Hello,
I have a table that looks like this:
table1:
col1 col2
100001 100001
210000 210000
210001 210000
211000 210000
212000 212000
220000 212000
230000 212000
240000 240000
241000 240000
241100 240000
241200 240000
I need to insert column 1 in another tabe
then retrieve the ID on the column 2 and insert in column 2 of the second table, either:
my table 2 must contains :
id col1 col2
1 100001 1
2 210000 2
3 210001 2
4 211000 2
5 212000 5
6 220000 5
7 230000 5
8 240000 8
9 241000 8
10 241100 8
11 241200 8
I tried this, but it only updates columns 1 and 2 identical my table1
after insertion of the col1 (in my table2)
update table2 set
table2.col2 = table2.id
from table1
where table1.col2=table2.col1