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 |
|
Rudys
Starting Member
8 Posts |
Posted - 2011-09-21 : 05:39:33
|
| Hai All,Please help me to solved this problem:first tablecol1 col2 col31 1 52 6 103 11 12Second tablecol1 col25 13 17 212 3explanation:I want to update a second table col2 with values from first table col1 based from between values col2 and col3 in first table.please help me, tq |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-21 : 05:53:10
|
| sorry that explanation doesnt make sense. you dont have any column in table2 to compare against col2 and col3 in table1. At least specify what should table look like after update and whats the logic for update------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Rudys
Starting Member
8 Posts |
Posted - 2011-09-22 : 00:53:23
|
| here the detail explanation:Table_ACol_Id _ Col_from _ Col_to1 ______ 1 __________52 ______ 6 __________103 ______ 11__________12Table_BCol_ID _ Col_Result5______ 17______ 212______ 3Row 1 Col_Result(Table_B) value '1' is from col_id(Table_A) because Co_id(Table_B) value '5'is between col_from(Table_A) and col_to(Table_A)Row 3 Col_Result(Table_B) value '3' is from col_id(Table_A) because Co_id(Table_B) value '12'is between col_from(Table_A) and col_to(Table_A)hope this explanation is clear, Please help me tq |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-22 : 00:57:23
|
| [code]UPDATE bSET b.Col_Result=a.Col_IDFROM Table_B bINNER JOIN TableA aON b.Col_ID >= a.Col_from AND b.Col_ID <= a.Col_to[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Rudys
Starting Member
8 Posts |
Posted - 2011-09-22 : 06:10:32
|
| solved my probelm. Thank you all. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-22 : 11:43:42
|
quote: Originally posted by Rudys solved my probelm. Thank you all.
you regarded me as all anyways welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|