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)
 Left Outer Join

Author  Topic 

msraja
Starting Member

2 Posts

Posted - 2006-03-06 : 22:13:27
Hi ALL
I am using this query to get data. but it throws dublicate records from the previous record . how to avoid this .
For Example,
Master Table has ID = 1,
For ID = 1 , Table1 has 2 records,
Table2 has 1 records
Table3 has 1 records . In the result,
second row of table 2 and table 3 should give null values . but it
through their 1 st record again


SELECT * FROM Master A
Left outer JOin Table1 B on A.ID = B.ID
Left outer JOin Table2 C on A.ID = C.ID
Left outer JOin Table3 D on A.ID = D.ID

Iam looking for your solutions









M S Raja |

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-06 : 23:40:20
msraja, sorry don't quite understand your problem. Can you post some sample data and the expected result ?

----------------------------------
'KH'


Go to Top of Page

msraja
Starting Member

2 Posts

Posted - 2006-03-07 : 03:34:39

SELECT * FROM Master A
Left outer JOin Table1 B on A.ID = B.ID
Left outer JOin Table2 C on A.ID = C.ID
Left outer JOin Table3 D on A.ID = D.ID


Master
----------
ID Name
------------
1 a
-------------

Table 1
-------------------------------------------------
ID test1 test2 test3
-------------------------------------------------
1 tbl1one tabl1two tbl1three
1 tbl1oneone tbl1onetwo tbl1onethree

-------------------------------------------------------

Table 2
-------------------------------------------------
ID test1 test2 test3
-------------------------------------------------
1 tbl2one tbl2two tbl2three


Table 3
-------------------------------------------------
ID test1 test2 test3
-------------------------------------------------
1 tbl3one tbl3two tbl3three




In the Left Outer Query Result
-------------------------------

Row 1
------
1 a 1 tbl1one tabl1two tbl1three 1 tbl2one tbl2two tbl2three 1 tbl3one tbl3two tbl3three

Row 2
------
1 a 1 tbl1oneone tbl1onetwo tbl1onethree 1 tbl2one tbl2two tbl2three 1 tbl3one tbl3two tbl3three

In the row2 it should only return table1 value only , remaining tabel2,3 should be null , But here it return existing value again

Plz check it . Thank you


M S Raja |
Go to Top of Page
   

- Advertisement -