Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update table1 based on value from table 2 in teradata

I have two tables like this

enter image description here

I would like to insert from Table1 to Table2 here. This is how I want it.

Take MOU = 10. It has num1 and hour1 in the same row. I would like to insert it into the cell that is at the same row as that of num1 and same column as that of hour1.

How could I do that?

Disclaimer: I am not offering any code here because I am unsure of how to write this query. I sure do know to write a simple update. I am a teracota newbie.

like image 976
naveen Avatar asked Dec 30 '25 18:12

naveen


1 Answers

This worked.

UPDATE a
FROM table2 a, table1 b
SET hour1=b.mou
WHERE a.access_method_id=b.access_method_id
AND hour='hour1'

Did the same for each hours. Not very elegant. But this is all I could get.

like image 109
naveen Avatar answered Jan 02 '26 09:01

naveen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!