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)
 Outer Joins

Author  Topic 

seran128
Starting Member

2 Posts

Posted - 2006-08-07 : 16:25:18
my SQL

SELECT Table1.*, Table2.Loc_Name, Table3.Inst_Name, Table4.Prg_Name 
FROM [Table1], [Table2] , [Table3], [Table4]
WHERE Table1.C_Id = 2001
AND Table2.L_Id = Table1.L_Id
AND Table3.I_Id = Table1.I_Id
AND Table4.F_Id = Table1.F_Id
ORDER by DT desc



I need to do an outer join instead of an inner join

because their could be no values for Table2, Table3, Table4

I still want a value returned and an inner join does not return any values for this query.

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2006-08-07 : 16:35:59
SELECT a.*, b.Loc_Name, c.Inst_Name, d.Prg_Name
FROM [Table1] a left join [Table2] b
on a.L_ID = b.L_ID Left Join [Table3] c
on a.I_ID = c.I_ID Left Join [Table4] d
on a.F_ID = d.F_ID
WHERE a.C_Id = 2001
ORDER by a.DT desc
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-08 : 01:22:46
quote:

I need to do an outer join instead of an inner join


There are 3 types of outer join, left outer join,right outer join and full outer join.
Based on the requirement of the query you need to choose what kind of join you want to apply.

It will better if you can post your requirement, then someone over here can help you out in solving your problem.

Chirag
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-08 : 13:13:43
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -