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 |
sweet_monic
Starting Member
3 Posts |
Posted - 2012-09-27 : 04:06:57
|
example i have 3 tablestable1A B Ca1 b1 c1a2 b2 c2a3 b3 c3table2C D Ec1 d1 e1c2 d2 e2c3 d3 e3table3E F Ge1 f1 g1e2 f2 g2e3 f3 g3the output i want istable1A B C Ga1 b1 c1 g1a2 b2 c2 g2a3 b3 c3 g3the select for G i got it select t3.G from table3 t3 join table2 t2 on t3.E = t2.Ejoin table3 t3 on t2.C=t3.C from this select i gotGg1g2g3so how i insert this data to table1 so the output is just like that? |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2012-09-27 : 04:18:30
|
[code]select t1.a ,t1.b ,t1.c ,t3.g from table1 as t1 inner join table2 as t2 on t2.c=t1.c inner join table3 as t3 on t3.e=t2.e[/code] |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2012-09-27 : 04:21:24
|
Try thisselect t1.A,t1.B,t1.C,t3.G from table1 t1 inner join table2 t2 on t1.C =t2.Cinner join table3 t3 on t2.E = t3.ESenthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
|
|
sweet_monic
Starting Member
3 Posts |
Posted - 2012-09-27 : 04:29:38
|
i want to insert to the existing table1i already alter table1 by add new field G can i do this?insert into [dbo].[table1] (G)select t3.G from table3 t3 join table2 t2 on t3.E = t2.E join table3 t3 on t2.C = t3.C |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2012-09-27 : 04:35:56
|
Then You have to go for Update with joinUpdate t1 set t1.E=t3.E from table1 t1 inner join table2 t2 on t1.C =t2.Cinner join table3 t3 on t2.E = t3.ESenthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
|
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2012-09-27 : 04:37:54
|
[code]update table1 set g=table3.g from table1 inner join table2 on table2.c=table1.c inner join table3 on table3.e=table2.e[/code] |
|
|
sweet_monic
Starting Member
3 Posts |
Posted - 2012-09-27 : 04:46:35
|
aaahhhh..... ic..ic...thank u all |
|
|
|
|
|