Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sanlen
Starting Member
29 Posts |
Posted - 2008-11-22 : 05:45:27
|
| Hi All,I have two tables as below:create table table1(tbl1_id int identity(1,1), name varchar(30), paying_rate moneyCONSTRAINT pk_table1_id PRIMARY KEY (tbl1_id))create table table2(tbl2_id int identity(1,1), tbl1_id int, project varchar(30), working_hour int, total moneyCONSTRAINT fk_tbl1_id FOREIGN KEY (tbl1_id) REFERENCES table1(tbl1_id))I want after inserting working_hour in that table2, then the total in table2 will equal to paying_rate (in table1) * working_hour (in table2)Could you please advise??Best Regard,SANLEN |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-22 : 11:05:46
|
| [code]UPDATE t2SET t2.total=t2.working_hour * t1.paying_rateFROM table1 t1INNER JOIN table2 t2ON t2.tbl1_id = t1.tbl1_id[/code] |
 |
|
|
|
|
|