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 |
|
rpr
Starting Member
3 Posts |
Posted - 2005-01-06 : 08:09:43
|
| Hello,Can i write a query to update fields in a row using values from two diferents tables? (How can i use the inner join?, etc) |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-06 : 08:21:00
|
something like: update t1set col1 = t2.col1,col2 = t2.col2from MyTable1 t1 inner join MyTable t2 on t1.id = t2.idGo with the flow & have fun! Else fight the flow |
 |
|
|
rpr
Starting Member
3 Posts |
Posted - 2005-01-06 : 08:59:38
|
| Hi again, I really dont get it, why did you put From MyTable1 t1 ?, whats MyTable?, look what i wrote in the query analizer:UPDATE [@Ventas_Enero_04]SET [@Ventas_Enero_04].Vtas_Cajas_est = [@Ventas_Enero_04].Vtas_Cajas * [@Conversion_cajas].CS_CFFrom mytable [@Conversion_cajas] inner Join mytable [@Ventas_Enero_04]On [@Ventas_Enero_04].Cod_articulo_sigma = [@Conversion_cajas].Articulo |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-06 : 09:05:05
|
well as i have no idea how your tables are named MyTable1 and MyTable are Table Names that you need to change to your table names.i'm guessing you're using table variables in your query, right? will this do?UPDATE t2SET Vtas_Cajas_est = t2.Vtas_Cajas * t1.CS_CFFrom [@Conversion_cajas] t1 inner Join [@Ventas_Enero_04] t2On t1.Cod_articulo_sigma = t2.ArticuloGo with the flow & have fun! Else fight the flow |
 |
|
|
rpr
Starting Member
3 Posts |
Posted - 2005-01-06 : 09:24:04
|
| Thanks a lot! i finnaly got it! |
 |
|
|
|
|
|