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 |
|
corgiii
Starting Member
4 Posts |
Posted - 2010-03-03 : 18:53:55
|
i'm trying to update a column of a table by selecting two different values from 2 different tables, i'm doing -UPDATE table_temp SET sum = table_temp.Point - table_RATING.Point and when trying that it pops up an error sayingThe multi-part identifier "table_RATING.Point" could not be bound. does anyone know what i'm doing wrong and show some examples? |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2010-03-03 : 19:14:50
|
you must use a correlated scalar subquery instead of column name of another tableOr you can use joinSee:JOINUPDATE T SET sum = T1.Point - T2.PointFROM table_temp T1JOIN table_RATING T2ON T1.id = T2.id Subquery:UPDATE TSET sum = T.Point - (SELECT Point FROM table_RATING WHERE id = T.idFROM table_temp T |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-04 : 02:17:06
|
quote: Originally posted by ms65g you must use a correlated scalar subquery instead of column name of another tableOr you can use joinSee:JOINUPDATE T SET sum = T1.Point - T2.PointFROM table_temp T1JOIN table_RATING T2ON T1.id = T2.id Subquery:UPDATE TSET sum = T.Point - (SELECT Point FROM table_RATING WHERE id = T.idFROM table_temp T
In the first example UPDATE Tshould beUPDATE T1MadhivananFailing to plan is Planning to fail |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-03-04 : 07:49:54
|
quote: Originally posted by ms65g you must use a correlated scalar subquery instead of column name of another tableOr you can use joinSee:JOINUPDATE T SET sum = T1.Point - T2.PointFROM table_temp T1JOIN table_RATING T2ON T1.id = T2.id Subquery:UPDATE TSET sum = T.Point - (SELECT Point FROM table_RATING WHERE id = T.idFROM table_temp T
Missing Closed Brace in SubQueryUPDATE TSET sum = T.Point - (SELECT Point FROM table_RATING WHERE id = T.id)FROM table_temp T |
 |
|
|
|
|
|