Table 1 -
| col1 | col2 |
|---|---|
| 1 | 443 |
| 2 | 449 |
| 3 | 479 |
Table 2 -
| col1 | col2 |
|---|---|
| 1 | NULL |
| 2 | NULL |
| 3 | NULL |
Note - col1 is not a PK
expected Output -
Table 2 -
| col1 | col2 |
|---|---|
| 1 | 443 |
| 2 | 449 |
| 3 | 479 |
This is my python code:
abc_df = pd.read_sql_query("UPDATE Table1 SET Table1_id = t2.col1 FROM Table1 t1
INNER JOIN Table2 t2 ON t1.col2 = t2.col2", con=connection)
But My Actual OUTPUT is -
Table 2 -
| col1 | col2 |
|---|---|
| 1 | 443 |
| 2 | 443 |
| 3 | 443 |