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 |
jaybat12
Starting Member
4 Posts |
Posted - 2006-06-16 : 15:46:37
|
in a table TBL1 I have to set DESCRIPTION for a TYPE1 equal to DESCRIPTION for a TYPE2 where their ID is equal in TBL1 and their key fields appear together in another table TBL2. In english, in TBL1 the description and id are equal but the type is different. a relationship between their key fields is shown in TBL2. Any thoughts on how to write this? |
|
SreenivasBora
Posting Yak Master
164 Posts |
Posted - 2006-06-16 : 16:12:05
|
Provide a simple exmple, it is easy to understand ...With RegardsBSR |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-19 : 02:15:25
|
General ApproachUpdate Tset col=S.colfrom TargetTable T inner join SourceTable Son T.keycol=S.keycolOtherwise post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
|
|
jaybat12
Starting Member
4 Posts |
Posted - 2006-06-19 : 08:52:13
|
In the example below I have to set the description of part 100085 equal to the description of part 100095.TBL1PART DESCRIPTION UNIQUE_ID100095 Handle Assembly 1242100085 100085 1275TBL2UNIQUE_ID_1 UNIQUE_ID_21242 1275 |
|
|
jaybat12
Starting Member
4 Posts |
Posted - 2006-06-19 : 08:55:10
|
The example above doesn't look much like I wanted it to. TBL1 has columns PART, DESCRIPTION, UNIQUE_ID. Part 100095 has description 'Handle Assembly' and unique_id 1242. part 100085 has description 100085 and unique_id 1275. TBL2 has columns UNIQUE_ID_1, UNIQUE_ID_2. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-19 : 09:41:30
|
[code]update t1set t1.DESCRIPTION = t3.DESCRIPTIONfrom TBL1 t1 inner join TBL2 t2 on t1.UNIQUE_ID = t2.UNIQUE_ID_2 inner join TBL1 t3 on t2.UNIQUE_ID_1 = t3.UNIQUE_ID[/code] KH |
|
|
jaybat12
Starting Member
4 Posts |
Posted - 2006-06-20 : 13:17:40
|
that does it. thanks. |
|
|
|
|
|