k2s Posted February 3, 2017 Report Posted February 3, 2017 Guys, I am not an expert in SQL, and here trying to join 3 tables. table 1 has some 10+ columns - when i execute this i am able to see all 10 columns table 2 & 3 are joined around 20 columns and when execute the query displays 20 columns now i want to join (table 1 and (table 2 and table 3) ) on certain condition. how do i do it ? calling @loveindia Quote
RamGopalVarma Posted February 3, 2017 Report Posted February 3, 2017 On SQL SERVER, Select T1.*,T2.*,T3.* FROM table1 T1 JOIN table2 T2 on T1. Primarykey=T2.foreignkey JOIN table3 T3 on T1.PrimaryKey=T3.foreinkey Quote
tennisluvr Posted February 3, 2017 Report Posted February 3, 2017 Not a SQL guy man sorry. @jbourneis an expert at SQL. Quote
k2s Posted February 3, 2017 Author Report Posted February 3, 2017 1 minute ago, RamGopalVarma said: On SQL SERVER, Select T1.*,T2.*,T3.* FROM table1 T1 JOIN table2 T2 on T1. Primarykey=T2.foreignkey JOIN table3 T3 on T1.PrimaryKey=T3.foreinkey First join table output emutundi? Quote
ARYA Posted February 3, 2017 Report Posted February 3, 2017 Exists Command kuda vadocchu thata or use joins Quote
GunturMirchiBajji Posted February 3, 2017 Report Posted February 3, 2017 29 minutes ago, k2s said: Guys, I am not an expert in SQL, and here trying to join 3 tables. table 1 has some 10+ columns - when i execute this i am able to see all 10 columns table 2 & 3 are joined around 20 columns and when execute the query displays 20 columns now i want to join (table 1 and (table 2 and table 3) ) on certain condition. how do i do it ? calling @loveindia em question idi 2 tables in 3 tables in N tables ina you will join the same way dude... Quote
k2s Posted February 4, 2017 Author Report Posted February 4, 2017 Just now, GunturMirchiBajji said: em question idi 2 tables in 3 tables in N tables ina you will join the same way dude... Konni examples na mohana padai nenu join chesi chusthey ouput blank osthundi Quote
BUDDY Posted February 4, 2017 Report Posted February 4, 2017 6 minutes ago, RamGopalVarma said: On SQL SERVER, Select T1.*,T2.*,T3.* FROM table1 T1 JOIN table2 T2 on T1. Primarykey=T2.foreignkey JOIN table3 T3 on T1.PrimaryKey=T3.foreinkey ila chesthey konni rows eguruthay ankunta ... i think u should use outer join .... anyways im not an expert so im not sure Quote
GunturMirchiBajji Posted February 4, 2017 Report Posted February 4, 2017 1 minute ago, k2s said: Konni examples na mohana padai nenu join chesi chusthey ouput blank osthundi Select T1.*,T2.*,T3.* FROM table1 T1 JOIN table2 T2 on T1. Primarykey=T2.foreignkey JOIN table3 T3 on T1.PrimaryKey=T3.foreinkey idigo example. If you want all the records that match the join condition use inner join or else if you want all the records in the table that don't match the join condition use left outer join dude. Above example is doing inner join. Quote
k2s Posted February 4, 2017 Author Report Posted February 4, 2017 53 minutes ago, GunturMirchiBajji said: Select T1.*,T2.*,T3.* FROM table1 T1 JOIN table2 T2 on T1. Primarykey=T2.foreignkey JOIN table3 T3 on T1.PrimaryKey=T3.foreinkey idigo example. If you want all the records that match the join condition use inner join or else if you want all the records in the table that don't match the join condition use left outer join dude. Above example is doing inner join. Got it... trying it now Quote
kiran karthik Posted February 4, 2017 Report Posted February 4, 2017 select t1.*,t.* from table1 t1, (select t2.* , t3.* from table2 t2, table3 t3 where t2.table2_pk = t3.table_fk) t where t1.table1_pk = t.table1_fk thumb rule joining n tables should have n-1 join conditions min Quote
hotmaddy Posted February 4, 2017 Report Posted February 4, 2017 Going to classes now. Select Statements varaku ayyindi. Please wait for 4 more months and LTT this thread. Quote
aatadista Posted February 4, 2017 Report Posted February 4, 2017 2 minutes ago, hotmaddy said: Going to classes now. Select Statements varaku ayyindi. Please wait for 4 more months and LTT this thread. Vadule apatiki unkle implementation ayipoi, holidays kuda tesukuntu vuntadu Quote
hotmaddy Posted February 4, 2017 Report Posted February 4, 2017 1 minute ago, aatadista said: Vadule apatiki unkle implementation ayipoi, holidays kuda tesukuntu vuntadu Anduke uncle wait cheyyamantunna. Quote
princeofheaven Posted February 4, 2017 Report Posted February 4, 2017 4 hours ago, kiran karthik said: select t1.*,t.* from table1 t1, (select t2.* , t3.* from table2 t2, table3 t3 where t2.table2_pk = t3.table_fk) t where t1.table1_pk = t.table1_fk thumb rule joining n tables should have n-1 join conditions min why re , idhi nannu okadu interview lo adigadu.. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.