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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 deleting duplicate columns from a join statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-28 : 21:07:10
kavitha writes "Hi guys….
I have a some difficulty which is related to joins… I would really like to know if there is a solution for this and if at all there is no solution then is there any alternative method for it…
I have 5 tables
Maintable,tab1,tab2,tab3,tab4 …
tab1,tab2,tab3,tab4 are 4 child tables whose parent table is maintable linked to each other by the id column…..
all the four tables have identical structures….
the columns of the maintable are name,id
the columns of tab1 are id,sel1 and the columns of tab2 are id,sel2 and the columns of tab3 are id,sel3 and the columns of tab4 are id,sel4
 MAINTABLE                  
Name id
Sam m1
Joe m2
Kim m3
Marc m4

TAB1
Id sel1
M1 rt
M1 rs
M1 vf
M2 ab
M2 vf
M3 rt

TAB2
Id sel2
M1 a
M1 c
M2 d
M3 d
M3 c
M4 y

TAB3
Id sel3
M2 t
M2 r
M3 t

TAB4
Id sel4
M1 e
M2 d
M3 e
M4 e


The id column of the maintable is a PRIMARY KEY. The id columns in the respective child tables are foreign key with respect to the primary key in the main table…
The result set I want to obtain should be in this form..i tried to do thid using joins but in vain…
Please help me…
Thank u..

Name	id	sel1	sel2	sel3	sel4
Sam m1 rt a null e
Sam m1 rs c null null
Sam m1 vf null null null
Joe m2 ab d r d
Joe m2 vf null null null
Kim m3 rt d t e
Kim m3 null c null null
Marc m4 null v null e



kavitha"
   

- Advertisement -